<!DOCTYPE html>
<html lang="zh-CN" id="AllWindow">
<script src="H:\新版地铁通\binshu.js"></script>
<script src="H:\新版地铁通\yongsheng.js"></script>
<script src="H:\新版地铁通\yiyang.js"></script>
<script src="H:\新版地铁通\weiyuan.js"></script>
<script src="H:\新版地铁通\maidu.js"></script>

<script>
    //'city': 城市,
    //'lineweb': 数据词条,
    //      'lineweb': [[线路1,颜色1,站1,站2......]......]
    //'stationdata': 变形图车站位置
    //      'stationdata':[{ "x": X坐标1, "y": Y坐标1, "name": 站名1, "line": 线路1, "color": 线路颜色1（不必须） }......]
    //'linedata': 线路数据
    //      'linedata': [{ 'name': 线路1, 'a': 加速度1(m/s2), 'v': 最大速度1(km/h), 'web': '所属线网1' }......]
    //'realposition': 实际走向位置,(暂未启用)
    //'realmap':实际走向地图,填写链接
    //'subwaymap':变形图,填写链接
    //'subwaymapData': 变形图数据
    //      'subwaymapData': {'x': 变形图宽(像素),'y': 变形图长(像素),'stationR': 变形图车站触及半径(像素)},
    //'webdata'：线网数据（价钱）
    //      'webdata': [{ 'basic': 基础价格1, 'per': 每公里单价1, 'name': '线网名称1' }......]
    const AllCityData = [
        {
            'country': '中海',
            'city': '咏胜',
            'lineweb': YongshengLd,
            'stationdata': AllCityData_YongSheng_stationdata,
            'stationMiddleWayData': AllCityData_YongSheng_stationMiddleWayData,
            'linedata': YongShengLines,
            'realposition': AllCityData_YongSheng_realposition,
            'realpositionMiddleWayData': AllCityData_YongSheng_realpositionMiddleway,
            'realmap': AllCityData_YongSheng_realmap,
            'subwaymap': 'http://static.wiki.jowei19.com/test/j3dryxyk.png',
            'subwaymapData': {
                'x': 5930,
                'y': 3995,
                'stationR': 30
            },
            'realmapData': {
                'x': 13094,
                'y': 10058,
                'stationR': 30,
                'rate': 1 / 75
            },
            'webdata': [
                { 'basic': 3, 'per': 0.2, 'name': '咏胜地铁' },
                { 'basic': 25, 'per': 0.5, 'name': '咏胜磁浮' }
            ]
        },
        {
            'country': '中海',
            'city': '威远',
            'lineweb': [],
            'stationdata': [],
            'linedata': [],
            'realposition': [],
            'realmap': '',
            'subwaymap': '',
            'subwaymapData': {
                'x': 0,
                'y': 0
            },
            'webdata': []
        },
        {
            'country': '中海',
            'city': '滨蜀',
            'lineweb': BINSHUlineweb,
            'stationdata': BINSHUstationdata,
            'linedata': BINSHUlinedata,
            'realposition': BINSHUstationdata,
            'realmap': BINSHUrealmap,
            'subwaymap': BINSHUrealmap,
            'stationMiddleWayData': BINSHUMdw,
            'realpositionMiddleWayData': BINSHUMdw,
            'subwaymapData': {
                'x': 5962,
                'y': 4399,
                'stationR': 8
            },
            'realmapData': {
                'x': 5962,
                'y': 4399,
                'stationR': 8,
                'rate': 3.83333/1000*5
            },
            'webdata': []
        },
        {
            'country': '新靖',
            'city': '麦都',
            'lineweb': [['1号线', '#e60012', '左家庄', '新兴镇', '霹雳门', '相思亭', '三角屯', '田生', '花园街', '西望', '星海街', '王岗', '洛殿', '游乐园', '海棠大道', '金融街', '蒙德路', '清泉镇', '平安大街', '新靖艺术宫', '祁镇', '老会堂', '麦津路', '黄海路', '和谐广场', '乐业西街', '铁道学院', '麦都北站', '新明路', '梅兰路', '文和路', '通海大道', '维京湾'], ['2号线', '#1d2088', '万宁村', '小潭', '万宝北', '铁桥', '万宝', '张岭路', '西宅', '冰橙路', '麦都西站', '建国广场', '香炉山北', '香炉山南', '奉天大街', '兴发新村', '麦都站', '晴空塔', '海棠大道', '万达广场', '环球金融中心', '创世纪桥', '宇通路', '提瓦特大道', '麦都大学', '学子街', '肝帝大厦', '麦块广场', '白鹿洞', '中山公园', '解放桥', '南长街', '南柯', '玉衡西路', '明华大街', '桃子园', '大塘', '胡家山', '北联路', '华古商城', '中海大街', '静沐里', '斜阳港', '远洋大街', '贤平路', '都津界', '小鲸湾', '海安公园', '皮都路', '金水'], ['3号线', '#fff100', '津州湾', '桃花巷', '安津大街', '同盟大街', '通联路', '宁和路', '春雨路', '蔡庄', '徐庄', '麦都南站', '飞卢街', '市二院', '师范大学', '科技大学', '天依路', '城管局', '大剧院', '麦块广场', '波江路', '斯诺小镇西', '拔刀剑厂', '空岛路', '麦都博物馆', '暮色路', '阿尔法广场', '枝江路', '东方之门', '浑林路', '明珠广场', '极客城', '极客湾'], ['4号线', '#3fc31f', '汕湾海滨', '海月路', '时灵亭', '麦州路', '汕湾新城', '嘉明南', '嘉明', '玉林寺', '元凤新村', '南海子', '左家庄', '南极街', '荣川路', '湛州路', '军工厂', '体育中心', '麦都南站', '南村', '米花美术馆', '星河路', '梁木', '和平公园', '慧海新村', '海关街', '常京路', '明华大街', '明华北', '东方大街', '万年大街', '大有坊', '沛景路', '彭清路', '极客湾', '太阳湖', '太平庄', '威安路', '扶桑路', '博硕路', '园艺街', '憨色路', '空港大道', '星云大街', '友谊路', '奋斗路', '松浦', '凌湾', '金麦湖'], ['5号线', '#66ccff', '秋实桥', '民主路', '华清池', '和谐广场', '安居街', '工业大学', '张三路', '法学院', '医科大学', '雪野路', '江北路', '通辽路', '离香街', '百灵桥', '阿尔法广场', '北塔', '麦谷', '东南楼', '解放桥', '殿帅府', '麦都东站', '同江街', '天依路', '乐正村', '言和路', '泠鸢大街', '福田路', '杏园', '创世纪桥', '蒙德路', '璃月路', '稻妻路', '须弥路', '枫丹路', '纳塔路', '至冬路', '秋实桥'], ['6号线', '#ea5514', '平安大街', '陈家坊', '拆迁队广场', '波江路', '匠魂路', '等价商店', '传送石碑', '东南楼', '南长街', '殿帅府', '麦都东站', '市政府', '凤凰街', '任家庄', '楚楼', '米花美术馆', '三家店北', '三家店', '世昭', '若宇庄', '津州北路', '市民中心', '津州学院', '富泽路', '津城广场'], ['7号线', '#7f4f21', '苏打路', '秋夕路', '水阳', '青莲路', '明月庄', '明月国际机场', '憨色路', '三二路', '威安路', '邛河路', '明珠广场', '新地街', '大有坊', '气象局', '明华东', '大塘', '大塘南', '樱林路', '新区医院', '格州东路', '宫礁路', '青芦街', '边防城', '云翔', '小窑', '兴坪', '宁川', '东滩'], ['8号线', '#666666', '和平公园', '格州路', '新区医院', '镜湖路', '中海大街', '滨海宫'], ['9号线', '#920783', '望尘球场', '砖瓦街', '李家庄', '海棠大道', '青州路', '会展中心', '璃月路', '轻策庄', '水上公园', '新靖艺术宫', '浑元塔', '斯诺小镇西', '斯诺小镇东', '末影路', '麦都博物馆', '穿山甲路', '可汗路', '宇宙路', '医科大学', '清溪路', '北岸绿地', '秋夕路', '北炮台', '金海岸'], ['10号线', '#009914', '邮轮中心', '同治街', '天后宫', '森林公园', '明影坞', '富强路', '民主路', '水晶广场', '老会堂', '抽象文化宫', '浑元塔', '拆迁队广场', '肝帝大厦', '北河路', '科技园', '泠鸢大街', '天明大街', '红旗北路', '木鱼石', '师范大学', '中通路', '凤凰街', '若霞西', '若霞', '清颖新村', '海关街'], ['11号线', '#c9a063', '精英街', '麦都站', '洛水桥', '海棠大道', '林盛路', '寒笛路', '集贤亭', '田生', '沙角炮台', '安宁门', '三道口', '先锋城', '元凤西', '元凤新村', '元凤东', '荣川南路', '广亭路', '泰文街', '体育中心南', '蔡庄', '风信子路', '三家店', '三家店东', '梁木南', '中海书院', '东坪路', '永春路', '格州路'], ['12号线', '#e4007f', '米仓', '沙角炮台', '相思亭', '中安门', '红星广场', '永安城', '大角镇', '杏园', '提瓦特大道', '平安大街', '新靖艺术宫', '抽象文化宫', '胜利路', '团结路', '新裕', '安居街', '乐业街', '麦都北站', '赤塘东', '北海大街', '洋明路', '洋平路', '蓝湾'], ['13号线', '#00a29a', '香炉山东', '松香源', '蝶香源', '纳塔路', '动物园', '水晶广场', '麦津路', '团结路', '一五街', '高塘路', '地达公墓', '可汗路', '通辽路', '北兴街', '戎新', '东方之门', '麦谷东', '东方大街', '明华北', '明华大街', '石粒路', '荣茂公园', '樱林路', '镜湖路', '静沐里'], ['14号线', '#a40b5d', '小西天', '彭家庄', '奉天大街', '江京大街', '言竹', '须弥路', '阿如村', '维摩庄', '市图书馆', '老会堂', '胜利路', '襄平广场', '高塘路', '理事街', '张三路', '朝晖路', '苏打南路', '北岸绿地', '水阳', '辉容苑', '后湾', '浦光'], ['15号线', '#fbb03b', '对青山', '万宝', '万友村', '万川路', '王玉屯', '双湖东路', '天后宫', '萨尔路', '海心大道', '北海大街', '同治街', '文和路', '苏打路'], ['16号线', '#0071bc', '襄平广场', '滨水公园', '拔刀剑厂', '斯诺小镇东', '匠魂路', '白鹿洞', '井石', '同江街', '科大东门', '中通路', '康安街', '南村北', '南村', '风信子路', '风访园', '鹿川街', '中央大街', '青年广场', '经纬路'], ['17号线', '#714691', '晴空塔', '洛水桥', '青州路', '金融街', '万达广场', '世林路', '世源路', '永安城', '大泽镇', '春尔滨路', '天明南大街', '红旗北路'], ['19号线', '#ed5296', '平宁庄', '双榆树', '麦都西站', '铁路局', '神泉', '秋实路', '民主路', '动物园', '维摩庄', '绀田村', '麦都原神城', '提瓦特大道', '杏园东', '福田路', '箭桥', '春尔滨路', '沛景路', '荣川路', '清明新村', '荣川南路', '阜春', '致新北', '致新南', '致南广场', '金榜阁', '时灵亭', '汕岱路', '汕湾体育中心'], ['20号线', '#943f61', '广竹开发区', '汕湾大学城', '永清', '汕湾新城', '状元府', '致新西', '致新东', '刘家庄', '动漫城', '特兰镇', '津州站', '通联路', '中央大街', '市民中心', '帕丁会馆', '广寒路', '白桦林', '凯旋大街', '化工厂', '杨柳路', '中海书院', '和平公园', '慧海街', '海关街', '樱林路', '华古商城', '滨海花园'], ['22号线', '#3a8e8c', '西城花园', '飞环乡', '广竹镇', '青港路', '嘉明', '纺织厂', '新德', '致新新城', '刘家庄北', '和州路', '宁和西路', '津州站', '津州站南广场', '安津大街', '经纬路', '富泽路'], ['23号线', '#c8e0b2', '传送石碑', '解放桥', '殿帅府东', '人民公园', '若霞', '若霞南', '星河路', '三家店东', '蒹葭路', '安洲路', '帕丁会馆', '麦津大学新太校区', '铁联街', '白桦林南', '香妃湖', '新太广场', '兴坪', '自扬路', '皮都路', '云观台'], ['27号线', '#f598b3', '麦都西站', '冰橙路', '西宅东', '万川南路', '神泉北', '龙王村', '明影坞', '孔明镇', '赤塘', '麦都北站', '工业大学', '执事街', '一五街', '襄平广场', '抽象文化宫', '祁镇', '市人大', '绀田村', '稻妻路', '铁路公园', '江京大街', '松香源', '平坊', '建国东路', '麦都西站']],
            'stationdata': [],
            'linedata': [],
            'realposition': [],
            'realmap': '',
            'subwaymap': 'http://static.wiki.jowei19.com/test/frhqr2cv.png',
            'subwaymapData': {
                'x': 6020,
                'y': 6430,
                'stationR': 30
            },
            'realmapData': {
                'x': 13094,
                'y': 10058,
                'stationR': 30,
                'rate': 1 / 75
            },
            'webdata': []
        }
    ]


    //下面的不用看
    function MakeAllSvgGray(){
        gr=`<!-- 定义灰度滤镜 -->
  <defs>
    <filter id="grayscale">
      <feColorMatrix type="matrix" values="0.3333 0.3333 0.3333 0 0
                                           0.3333 0.3333 0.3333 0 0
                                           0.3333 0.3333 0.3333 0 0
                                           0      0      0      1 0"/>
    </filter>
  </defs>
  
  <!-- 应用灰度滤镜到所有SVG元素 -->
  <rect width="100%" height="100%" filter="url(#grayscale)" />`
    }
    function convertSecondsToHMS(seconds) {
            var hours = Math.floor(seconds / 3600);
            var minutes = Math.floor((seconds % 3600) / 60);
            var remainingSeconds = seconds % 60;
            return [hours, minutes, remainingSeconds]
        }
        function convertSecondsToHMS2(seconds) {
            dqew = convertSecondsToHMS(seconds)
            return dqew
        }
        function removeParenthesesContent(str) {
            return str.replace(/\（.*?\）/g, '').replace(/\(.*?\)/g, '');
        }
        var NewData = []
        function convertSecondsToHMS(seconds) {
            var hours = Math.floor(seconds / 3600);
            var minutes = Math.floor((seconds % 3600) / 60);
            var remainingSeconds = seconds % 60;

            return parseInt(hours) + ":" + parseInt(minutes) + ":" + parseInt(remainingSeconds);
        }
        function IsABStation(n1, l1, n2, l2) {
            if (!Check(n1)) {
                return false
            }
            if (!Check(n2)) {
                return false
            }
            if (!Check(l1)) {
                return false
            }
            if (!Check(l2)) {
                return false
            }
            if (l1 != l2) {
                return false
                //线路不一样怎么可能连着？
            }
            var xw = ThisCity.lineweb
            var IndexOfN1 = xw.find(x => x[0] == l1).indexOf(n1)
            var IndexOfN2 = xw.find(x => x[0] == l2).indexOf(n2)
            if (Math.abs(IndexOfN1 - IndexOfN2) == 1) {
                return true
            }
            return false
        }

        //查询两站直接有没有中间点
        function FindMiddleWay(n1, l1, n2, l2) {
            //正着看一遍
            var Midways = ThisCity.stationMiddleWayData.filter(x => x.name1 == n1 && x.name2 == n2 && x.line1 == l1 && x.line2 == l2)
            if (Midways.length != 0) {
                Midways = Midways.sort((a, b) => {
                    return a.mwindex - b.mwindex
                })
                return Midways
            }
            else {//反着看
                var Midways2 = ThisCity.stationMiddleWayData.filter(x => x.name1 == n2 && x.name2 == n1 && x.line1 == l2 && x.line2 == l1)
                if (Midways2.length != 0) {
                    Midways2 = Midways2.sort((a, b) => {
                        return -a.mwindex + b.mwindex
                    })
                    return Midways2
                }
                else {
                    return []
                }
            }
        }
        function FindMiddleWayRealmap(n1, l1, n2, l2) {
            //正着看一遍
            var Midways = ThisCity.realpositionMiddleWayData.filter(x => x.name1 == n1 && x.name2 == n2 && x.line1 == l1 && x.line2 == l2)
            if (Midways.length != 0) {
                Midways = Midways.sort((a, b) => {
                    return a.mwindex - b.mwindex
                })
                return Midways
            }
            else {//反着看
                var Midways2 = ThisCity.realpositionMiddleWayData.filter(x => x.name1 == n2 && x.name2 == n1 && x.line1 == l2 && x.line2 == l1)
                if (Midways2.length != 0) {
                    Midways2 = Midways2.sort((a, b) => {
                        return -a.mwindex + b.mwindex
                    })
                    return Midways2
                }
                else {
                    return []
                }
            }
        }
        function CalcuateDistance(x1, x2, y1, y2) {
            return Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)//单位：米
        }
        function FindTransferLines(n, l) {
            var transfer = ThisCity.lineweb.filter(x => x.includes(n) && x[0] != l && x[0] != l + '支线' && x[0] + '支线' != l)
            return transfer
        }
        function GenerateLineAu(lwbe) {
            tt = '\t'
            tn = '\n'
            allr = ''
            lwbe.forEach(l => {
                c = l[1]
                n = l[0]
                liner = `${n}${tn}AuRtRd(c:${c})`

                for (var i = 2; i < l.length; i++) {
                    s = l[i]
                    airport = '_机场_'
                    if (!s.includes('机场')) {
                        airport = ''
                    }
                    trans = FindTransferLines(s, n)
                    tr = ``
                    trans.forEach(Tran => {
                        Num = findAlphanumericsBeforeHash(Tran[0])
                        if (Num==''|| Num.length==0){
                            Num= Tran[0].charAt(0)+ Tran[0].charAt(1)
                        }
                        Colo = Tran[1]
                        tr += `${Num}(${Colo});`
                    });
                    liner += `o_;${tr}${airport}${tt}${s}${tn}`
                }
                liner += `${tn}`
                allr += liner
            });
            copyTextToClipboard(allr)
            return allr
        }
        function GenerateLineAu2() {
            GenerateLineAu(ThisCity.lineweb)
        }
        function GetLineNumber(n) {
            if (n.includes('号线')) {
                Num = findNumberBeforeStr(n, '号线')
            }
            else {
                Num = n.charAt(0) + n.charAt(1)
            }
            return Num
        }
        function CalcuateStationDistance(n1, n2, Line) {
            var XY1 = FindXYbyNameLineRealmap(n1, Line)
            var XY2 = FindXYbyNameLineRealmap(n2, Line)
            var Midway = FindMiddleWayRealmap(n1, Line, n2, Line)
            if (Line.includes('支线')) {
                MainLineName = Line.replaceAI('支线', '')
                MainLine = ThisCity.lineweb.find(x => x[0] == MainLineName)
                if (MainLine != undefined) {
                    var XY3 = MainLine.indexOf(n1)
                    var XY4 = MainLine.indexOf(n2)
                    if (XY3 != -1 && XY4 != -1) {
                        if (Math.abs(XY3 - XY4) == 1) {
                            Line = MainLineName
                            XY1 = FindXYbyNameLineRealmap(n1, Line)
                            XY2 = FindXYbyNameLineRealmap(n2, Line)
                            Midway = FindMiddleWayRealmap(n1, Line, n2, Line)
                        }
                    }
                }
            }
            var Distance = 0
            if (XY1 == undefined) {
                return 0
            }
            if (Midway.length == 0) {
                Distance += CalcuateDistance(XY1.x, XY2.x, XY1.y, XY2.y)
            }
            else {
                if (Midway[0].mwindex < Midway[Midway.length - 1].mwindex) {
                    //正着来的
                    Distance += CalcuateDistance(XY1.x, Midway[0].x, XY1.y, Midway[0].y)
                    for (var i = 0; i < Midway.length - 1; i++) {
                        var MidPoint = Midway[i]
                        var NextMidPoint = Midway[i + 1]
                        Distance += CalcuateDistance(MidPoint.x, NextMidPoint.x, MidPoint.y, NextMidPoint.y)
                    }
                    Distance += CalcuateDistance(Midway[Midway.length - 1].x, XY2.x, Midway[Midway.length - 1].y, XY2.y)
                }
                else if (Midway[0].mwindex > Midway[Midway.length - 1].mwindex) {
                    //反着来的
                    Distance += CalcuateDistance(XY1.x, Midway[0].x, XY1.y, Midway[0].y)
                    for (var i = 0; i < Midway.length - 1; i++) {
                        var MidPoint = Midway[i]
                        var NextMidPoint = Midway[i + 1]
                        Distance += CalcuateDistance(MidPoint.x, NextMidPoint.x, MidPoint.y, NextMidPoint.y)
                    }
                    Distance += CalcuateDistance(Midway[Midway.length - 1].x, XY2.x, Midway[Midway.length - 1].y, XY2.y)
                }
                else if (Midway[0].mwindex == Midway[Midway.length - 1].mwindex) {
                    //只有一个midway
                    Distance += CalcuateDistance(XY1.x, Midway[0].x, XY1.y, Midway[0].y)
                    Distance += CalcuateDistance(XY2.x, Midway[0].x, XY2.y, Midway[0].y)
                }
            }
            return Distance * ThisCity.realmapData.rate
        }
        function CalcuateLineDataToATable(l) {
            var Line = ThisCity.lineweb.find(x => x[0] == l)
            if (Line == undefined) {
                return ''
            }
            c = Line[1]
            CRGB = hexToRgb(c)
            CHSB = rgbToHsb(CRGB[0], CRGB[1], CRGB[2])
            CHSBLight = [CHSB[0], 25, 100]
            CHSBLightPlus = [CHSB[0], 13, 100]
            cLight = rgbToHex(hsbToRgb(CHSBLight))
            cPlus = rgbToHex(hsbToRgb(CHSBLightPlus))
            Linedatas = ThisCity.linedata.find(x => x.name == l)
            if (Linedatas == undefined) {
                if (l.includes('支线')) {
                    loi = l.replaceAI('支线', '')
                    Linedatas = ThisCity.linedata.find(x => x.name == loi)
                }
                else {
                    return ''
                }
            }
            AllD = 0
            AllT = 0
            var Table = `<table><tbody><tr><td><b>序号</b></td><td><b>区间</b></td><td><b>站距</b></td><td><b>时间</b></td><td><b>速度</b></td><td><b>里程</b></td><td><b>耗时</b></td><td><b>均速</b></td></tr><tr><td colspan="8" style="color:${ChooseWhiteBlack(c)};background-color:${c}">${l}|加速度${Linedatas.a}m/s<sup>2</sup>|最大速度${Linedatas.v}km/h</td></tr>`;
            for (var s = 2; s < Line.length - 1; s++) {
                s1 = Line[s]
                s2 = Line[s + 1]
                d = CalcuateStationDistance(s1, s2, l) * 1000
                AllD += d
                t = CalcuateTimeByDistance(d, Linedatas.v, Linedatas.a, 35)
                AllT += t
                if (s % 2 == 0) {
                    Table += `
            <tr style="background-color:${cLight}"><td>${s - 1}</td><td>${s1}→${s2}</td><td>${parseInt(d)}m</td><td>${parseInt(t)}s</td><td>${parseInt(d / t * 3.6)}km/h</td><td>${(parseInt(AllD) / 1000).toFixed(1) }km</td><td>${convertSecondsToHMS2(parseInt(AllT)) }</td><td>${parseInt(AllD / AllT * 3.6)}km/h</td></tr>
            `
                }
                if (s % 2 == 1) {
                    Table += `
            <tr style="background-color:${cPlus}"><td>${s - 1}</td><td>${s1}→${s2}</td><td>${parseInt(d)}m</td><td>${parseInt(t)}s</td><td>${parseInt(d / t * 3.6)}km/h</td><td>${(parseInt(AllD)/1000).toFixed(1) }km</td><td>${convertSecondsToHMS2(parseInt(AllT))}</td><td>${parseInt(AllD / AllT * 3.6)}km/h</td></tr>
            `
                }
            }
            Table += '</tbody></table>'
            return Table
        }
    
    function RemoveTwiceAppearPosition() {
        AllCityData.forEach(CityDataItem => {
            var NewCityDatasstationdata = []
            CityDataItem.stationdata.forEach(q => {
                if (NewCityDatasstationdata.filter(x => x.name == q.name && x.line == q.line).length == 0) {
                    NewCityDatasstationdata.push(q)
                }
            });
            CityDataItem.stationdata = NewCityDatasstationdata
        });
    }
    
        function findAlphanumericsBeforeHash(str) {
            const results = str.match(/\b\w+(?=号线)/g);
            return results || [];
        }

    //找到某字符串前面的数字
    function findNumberBeforeStr(str, chart) {
        const reg = new RegExp(`(\\d+)\\s*${chart}`, 'g')
        const match = str.matchAll(reg)
        let num_arr = []
        for (const m of match) {
            num_arr.push(m[1])

        }
        return num_arr[0]
    }

    function LineNameSort(ls) {
        ls = ls.sort((a, b) => {
            if (a.name.includes('号线') && b.name.includes('号线')) {
                return parseInt(findNumberBeforeStr(a.name)) - parseInt(findNumberBeforeStr(b.name))
            }
            else if (a.name.includes('号线') && false == b.name.includes('号线')) {
                return -1
            }
            else if (b.name.includes('号线') && false == a.name.includes('号线')) {
                return 1
            }
            return a.name.localeCompare(b.name)
        })
        return ls
    }
    function LineNameSortLineWeb(ls) {
        ls = ls.sort((a, b) => {
            if (a[0].includes('号线') && b[0].includes('号线')) {
                return (parseInt(findNumberBeforeStr(a[0])) - parseInt(findNumberBeforeStr(b[0])))
            }
            else if (a[0].includes('号线') && false == b[0].includes('号线')) {
                return -1
            }
            else if (b[0].includes('号线') && false == a[0].includes('号线')) {
                return 1
            }
            return a[0].localeCompare(b[0])
        })
        return ls
    }
    AllCityData.forEach(acd => {
        acd.lineweb = LineNameSortLineWeb(acd.lineweb)
    });
</script>

<style id="EditLineColor"></style>
<script>
    function hexToRgb(hex) {
        // 去除可能包含在颜色值中的#号
        hex = hex.replace("#", "");

        // 通过正则匹配提取R、G、B的十六进制值
        var r = parseInt(hex.substring(0, 2), 16);
        var g = parseInt(hex.substring(2, 4), 16);
        var b = parseInt(hex.substring(4, 6), 16);

        // 返回RGB格式的颜色值
        return [r, g, b];
    }
    function rgbToHex(rgb) {
        const toHex = (colorValue) => {
            const hex = colorValue.toString(16);
            return hex.length == 1 ? "0" + hex : hex;
        };

        return "#" + toHex(rgb[0]) + toHex(rgb[1]) + toHex(rgb[2]);
    }
    function hsbToRgb(hsb) {
        hue = hsb[0]
        saturation = hsb[1]
        brightness = hsb[2]
        let red, green, blue;
        let h = hue / 60;
        let s = saturation / 100;
        let v = brightness / 100;

        let i = Math.floor(h);
        let f = h - i;
        let p = v * (1 - s);
        let q = v * (1 - f * s);
        let t = v * (1 - (1 - f) * s);

        switch (i % 6) {
            case 0: red = v, green = t, blue = p; break;
            case 1: red = q, green = v, blue = p; break;
            case 2: red = p, green = v, blue = t; break;
            case 3: red = p, green = q, blue = v; break;
            case 4: red = t, green = p, blue = v; break;
            case 5: red = v, green = p, blue = q; break;
        }

        return [
            Math.round(red * 255),
            Math.round(green * 255),
            Math.round(blue * 255)
        ];
    }
    //遗留记忆
    TheLastCreatedPoint = {}
    TheNextCreatedPoint = {}
    IsABStationF = false
    MiddleWayIndex = 0
    //补录记忆
    AddingLine = 0
    AddingStation = 2
    AddingMiddleWayIndex = 0
    //处理键盘
    var CtrlKey = false
    var ShiftKey = false
    var AltKey = false
    var WinKey = false
    function SetAllKeyFalse() {
        CtrlKey = false
        ShiftKey = false
        AltKey = false
        WinKey = false
    }
    document.addEventListener('keydown', function (event) {
        if (event.ctrlKey) {
            SetAllKeyFalse()
            CtrlKey = true
        }
        if (event.altKey) {
            SetAllKeyFalse()
            AltKey = true
            hiddentrue('NormalNotice1')
            hiddentrue('NormalNotice2')
            unhide('AddingNotice1')
            unhide('AddingNotice2')
        }
        if (event.shiftKey) {
            SetAllKeyFalse()
            ShiftKey = true
        }
    });
    document.addEventListener('keyup', function (event) {
        if (event.key === 'Control') {
            SetAllKeyFalse()
        }
        if (event.key === 'Alt') {
            hiddentrue('AddingNotice1')
            hiddentrue('AddingNotice2')
            unhide('NormalNotice1')
            unhide('NormalNotice2')
            SetAllKeyFalse()
        }
        if (event.key === 'Shift') {
            SetAllKeyFalse()
        }
        if (event.key === 'Enter' && AltKey) {
            AddingLine += 1
            AddingMiddleWayIndex = 0
            AddingStation = 2
        }
    });
</script>
<style>
    .yxjk {
        z-index: 53
    }

    #EditorCircle {
        z-index: 240
    }

    .SpawnEditor {
        z-index: 231;
    }

    .YuanXingJk {
        cursor: pointer;
        z-index: 231;
    }

    .whitething {
        color: white
    }

    .subwaymap {
        width: 100%;
    }
</style>
<style id="Ocp">
    .diers {
        opacity: 0.7;

    }
</style>
<style>
    .diyi {
        position: absolute;
    }

    .dier {
        z-index: 20;
        position: absolute;
        opacity: 0.0;

    }

    .圆形jk {
        left: -7px;
        top: -7px;
        background-color: #EEEEEE;
        border-radius: 50%;
        width: 14px;
        height: 14px;
        position: relative;
        border-color: #222222;
        border-radius: 12px;
        border-width: 1px;
        border-style: solid;
        z-index: 20;
    }

    .diers {
        z-index: 20;
        position: absolute;

    }

    .圆形jk22 {
        left: -8px;
        top: -8px;
        background-color: #ff9100;
        border-radius: 50%;
        width: 16px;
        height: 16px;
        position: relative;
        border-color: #070707;
        border-radius: 12px;
        border-width: 1px;
        border-style: solid;
        z-index: 20;
    }

    .StartNodeItemCss {
        left: -7px;
        top: -7px;
        background-color: #10c000;
        color: #10c000;
        border-radius: 50%;
        width: 14px;
        height: 14px;
        position: relative;
        border-radius: 12px;
        border-width: 1px;
        border-style: solid;
        z-index: 20;
    }

    .EndNodeItemCss {
        left: -7px;
        top: -7px;
        background-color: #f10707;
        color: #f10707;
        border-radius: 50%;
        width: 14px;
        height: 14px;
        position: relative;
        border-radius: 12px;
        border-width: 1px;
        border-style: solid;
        z-index: 20;
    }

    .zhanju {
        user-select: all;
    }
</style>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>寻路初级</title>
</head>

<body>
    <span id="notices" style="user-select: none;"></span>
    <table style="user-select: none;">
        <tbody>
            <tr>
                <td onclick="ReloadAll()" style="color:darkred">
                    重置页面
                </td>
                <td class="whitething">---</td>
                <td>
                    <div id="citychoose">
                        <span>切换城市</span>
                        <select id="citychange" onchange="reloadmap();ReloadZhanju()">

                        </select>
                    </div>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('lujing')">
                    <span href="" id="lujing1" style="color:#000">路径模式</span>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('xianlutu')">
                    <span href="" id="xianlutu1" style="color:#777">看线路图</span>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('ditu')">
                    <span href="" id="ditu1" style="color:#777">地图模式</span>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('chezhan')">
                    <span href="" id="chezhan1" style="color:#777">车站列表</span>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('xianlu')">
                    <span href="" id="xianlu1" style="color:#777">线路列表</span>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('zhanju')">
                    <span href="" id="zhanju1" style="color:#777">站距信息</span>
                </td>
                <td class="whitething">---</td>
                <td onclick="changemode('xianlutubianji')">
                    <span href="" id="xianlutubianji1" style="color:#777">改线路图</span>
                </td>
                <td class="whitething">---</td>
            </tr>
        </tbody>
    </table>

    <div id="YinCang" style="user-select: none;">
        <table>
            <tbody>

                <tr>
                    <td>
                        起点
                    </td>

                    <td>
                        <input type="text" id="local" onchange="shiftd()">
                    </td>
                    <td class="w">
                        ---
                    </td>

                    <td>
                        终点
                    </td>
                    <td>
                        <input type="text" id="dest" onchange="shiftd()">
                    </td>
                    </td>
                    <td class="w">
                        ---
                    </td>
                </tr>
                <tr>
                    <td>
                        选取起点
                    </td>
                    <td id="start1">
                        <button
                            onclick="hide('floatLineSelect1');hiddentrue('floatStaSelect2End');hiddentrue('floatStaSelect2')">选择</button>

                    </td>
                    <td id="start2">

                    </td>
                    <td>
                        选取终点
                    </td>
                    <td id="end1">
                        <button
                            onclick="hide('floatLineSelect1End');hiddentrue('floatLineSelect1');hiddentrue('floatStaSelect2')">选择</button>
                    </td>
                    <td id="end2">

                    </td>
                </tr>

            </tbody>
        </table>

        <div class="floatingwindow" id="floatLineSelect1" hidden>
            <div class="floatingwindowcontent" id="floatLineSelect1d">
                <button onclick="hide('floatLineSelect1');hiddentrue('floatStaSelect2')" class="floatingwindowcontent"
                    style="z-index:100;font-size: large;color:red">X</button>选择起始线路
            </div>
        </div>
        <div class="floatingwindow2" id="floatStaSelect2" hidden>
            <div class="floatingwindowcontent2" id="floatStaSelect1d">
                <button onclick="hide('floatStaSelect2')" class="floatingwindowcontent2"
                    style="z-index:105;font-size: large;color:red">X</button>选择起始车站
                <span id="cfs1"></span>
            </div>
        </div>

        <div class="floatingwindowEnd" id="floatLineSelect1End" hidden>
            <div class="floatingwindowcontentEnd" id="floatLineSelect1dEnd">
                <button onclick="hide('floatLineSelect1End');hiddentrue('floatStaSelect2End')"
                    class="floatingwindowcontentEnd" style="z-index:100;font-size: large;color:red">X</button>选择终到线路
            </div>
        </div>
        <div class="floatingwindow2End" id="floatStaSelect2End" hidden>
            <div class="floatingwindowcontent2End" id="floatStaSelect1dEnd">
                <button onclick="hide('floatStaSelect2End')" class="floatingwindowcontent2End"
                    style="z-index:105;font-size: large;color:red">X</button>选择终到车站
                <span id="cfs1End"></span>
            </div>
        </div>
        <span onclick="GenerateLineAu2()">生成AU插件的线路图</span>
    </div>
    <div>
        <div id="resultUI" style="user-select: none;"></div>
    </div>
    <div id="xianlutu" hidden style="user-select: none;">
        <svg id="linemap" height="100%" width="100%" viewBox="0 0 4000 4000"></svg>
    </div>
    <div id="ditu" hidden style="user-select: none;">
        <svg id="realmap" height="100%" width="100%" viewBox="0 0 4000 4000"></svg>
    </div>
    <div id="chezhan" hidden>
    </div>
    <div id="xianlu" hidden>
    </div>
    <div id="zhanju" hidden></div>
    <script>
        function rgbToHsb(r, g, b) {
            r /= 255;
            g /= 255;
            b /= 255;

            var max = Math.max(r, g, b), min = Math.min(r, g, b);
            var h, s, v = max;

            var d = max - min;
            s = max === 0 ? 0 : d / max;

            if (max === min) {
                h = 0; // achromatic
            } else {
                switch (max) {
                    case r: h = (g - b) / d + (g < b ? 6 : 0); break;
                    case g: h = (b - r) / d + 2; break;
                    case b: h = (r - g) / d + 4; break;
                }
                h /= 6;
            }

            return [
                Math.round(h * 360),
                Math.round(s * 100),
                Math.round(v * 100)
            ];
        }
        function ShuaXinYouCe() {
            var ressd = GetAllPositionDataOfSubwayMap()
            var jsonStr = JSON.stringify(ressd);
            WriteById('xianlutubianjixianshi', jsonStr)
            var StationThatNotHavePosition = FindStationThatNotHavePosition()
            if (StationThatNotHavePosition.length > 1) {
                WriteById('ticizhan', StationThatNotHavePosition[1].name)
                WriteById('ticixian', StationThatNotHavePosition[1].line)
                document.getElementById('ticise').style.backgroundColor = GetColorByLineName(StationThatNotHavePosition[1].line)
                document.getElementById('ticise').style.color = GetColorByLineName(StationThatNotHavePosition[1].line)
            }
        }
        function ShuaXinYouCeMiddleway() {
            var ressd2 = GetAllMiddleWayDataOfSubwayMap()
            var jsonStr2 = JSON.stringify(ressd2);
            WriteById('xianlutubianjixianshiMiddleway', jsonStr2)
        }
        var MouseX = 0
        var MouseY = 0
    </script>
    <div id="xianlutubianji" hidden us="a" style="user-select: none;">
        <svg id="linemapedit" height="100%" width="100%" viewBox="0 0 4000 4000" style="user-select: none;"></svg>
        <div class="moveWarn" style="user-select: none;">
            <span id="NormalNotice1">
                <span style="font-size: large;color:darkmagenta">单独左键滑动：移动位置</span>
                <span style="font-size: large;color:darkblue">鼠标悬停：看站名线路</span>
                <span style="font-size: large;color:rgb(134, 74, 0)">ctrl+左键：移动节点</span>
                <span style="font-size: large;color:darkred">ctrl+右键：删除节点</span>
                <span style="font-size: large;color:darkgreen">shift+左键：新增节点</span>
                <span style="font-size: large;color:rgb(0, 95, 124)">shift+右键：新增区间中间点</span>
            </span>
            <span id="AddingNotice1" hidden>
                <span style="font-size: large;color:rgb(162, 0, 0)">Alt左键补录区间</span>
                <span style="font-size: large;color:rgb(3, 109, 166)">Alt右键跳过区间</span>
                <span style="font-size: large;color:rgb(10, 123, 0)">Alt+Enter跳过线路</span>
            </span>
            <span style="font-size: large;color:darkred">当前鼠标位置：(<span id="NowX"></span>,<span id="NowY"></span>)</span>
            <br>
            <span id="NormalNotice2">
                <span style="font-size: smaller;">上一个录入的是：<span id="shangyigelurudeshi"></span></span>
                提词器：你即将录入位置的是：<b id="ticizhan"></b>|<b id="ticixian"></b>|<span id="ticise">-------</span>
            </span>
            <span id="AddingNotice2" hidden>
                <span>提词器：目前正在录入：<b id="AddingLine"></b>|<span id="AddingLineColor">-------</span>|<b
                        id="AddingStation1"></b>-><b id="AddingStation2"></b></span>
            </span>
            <br>
            <button onclick="OpenBar()"><span style="font-size: larger;" id="OpenBar">复制节点到剪贴板</span></button>

            <button onclick="OpenBarMiddleway()"><span style="font-size: larger;"
                    id="OpenBar2">复制中间点到剪贴板</span></button>

            <input type="number" id="MoveEast"><button onclick="MoveEast()"><span
                    style="font-size:larger;">整体向右移动（向左负数）</span></button>

            <input type="number" id="MoveSouth"><button onclick="MoveSouth()"><span
                    style="font-size:larger;">整体向下移动（向上负数）</span></button>
            <div id="xianlutubianjixianshi" hidden></div>
            <div id="xianlutubianjixianshiMiddleway" hidden></div>
        </div>
    </div>
    <script>
        function MoveEast() {
            var MoDi = parseInt(MoveDistance = document.getElementById('MoveEast').value)
            if (Check(MoveDistance = document.getElementById('MoveEast').value)) {
                var AllNodePoint = FindAllThisId('EditorCircle')
                AllNodePoint.forEach(AllNodePointItem => {
                    AllNodePointItem.setAttribute('cx', parseInt(AllNodePointItem.getAttribute('cx')) + MoDi)
                });
                AllNodePoint = FindAllThisId('MiddleWayCircle')
                AllNodePoint.forEach(AllNodePointItem => {
                    AllNodePointItem.setAttribute('cx', parseInt(AllNodePointItem.getAttribute('cx')) + MoDi)
                });
                ShuaXinYouCe();
                ShuaXinYouCeMiddleway()
            }
        }
        function MoveSouth() {
            var MoDi = parseInt(MoveDistance = document.getElementById('MoveSouth').value)
            if (Check(MoveDistance = document.getElementById('MoveSouth').value)) {
                var AllNodePoint = FindAllThisId('EditorCircle')
                AllNodePoint.forEach(AllNodePointItem => {
                    AllNodePointItem.setAttribute('cy', parseInt(AllNodePointItem.getAttribute('cy')) + MoDi)
                });
                AllNodePoint = FindAllThisId('MiddleWayCircle')
                AllNodePoint.forEach(AllNodePointItem => {
                    AllNodePointItem.setAttribute('cy', parseInt(AllNodePointItem.getAttribute('cy')) + MoDi)
                });
                ShuaXinYouCe();
                ShuaXinYouCeMiddleway()
            }
        }
        function Check(s) {
            return (s != null && s != undefined && s != 0 && s != '' && s != NaN)
        }
        async function copyTextToClipboard(text) {
            try {
                await navigator.clipboard.writeText(text);
            } catch (err) {
                console.error('Failed to copy: ', err);
            }
        }

        // 从剪贴板粘贴文本
        async function pasteTextFromClipboard() {
            try {
                const text = await navigator.clipboard.readText();
                console.log('Pasted text: ', text);
                return text;
            } catch (err) {
                console.error('Failed to paste: ', err);
            }
        }
        function OpenBar() {
            ShuaXinYouCe()
            copyTextToClipboard(document.getElementById('xianlutubianjixianshi').innerHTML)
        }
        function OpenBarMiddleway() {
            ShuaXinYouCeMiddleway()
            copyTextToClipboard(document.getElementById('xianlutubianjixianshiMiddleway').innerHTML)
        }
    </script>
    <style>
        .moveWarn {
            color: rgb(0, 0, 0);
            background-color: #EEEEEE;
            position: fixed;
            bottom: 0px;
            left: 0px;
            right: 0px;
            font-size: xx-large;
            text-align: center;
        }
    </style>
    <div id="cav"></div>
    <div class="floatingwindowPoint" id="floatingwindowPoint" hidden>
        <button onclick="hide('floatingwindowPoint')" class="floatingwindowcontentsqd"
            style="z-index:100;font-size: large;color:red">X</button>
        <div class="floatingwindowPointStationName" id="floatingwindowPointStationName">

        </div>
        <span onclick="SetStart();hide('floatingwindowPoint')" style="color:darkgreen">设为起点</span>
        <span onclick="SetEnd();hide('floatingwindowPoint')" style="color:darkred">设为终点</span>
    </div>
    <script>
        var ThenMouseMoveWhatItem = ''
        var ThisCity = []
        var YRate = 1333
        const modes = `lujing xianlutu ditu chezhan xianlu xianlutubianji zhanju`.split(' ')
        function updateSliderValue(v) {
            YRate = v
        }
        function GetColorByLineName(l) {
            return ThisCity.lineweb.find(x => x[0] == l)[1]
        }
        function changemode(mode) {
            if (!modes.includes(mode)) {
                return;
            } document.getElementById('AllWindow').style.overflow = 'auto'
            if (mode == 'xianlutu') {
                if (document.getElementById('xianlutu').hidden == true) {
                    document.getElementById('AllWindow').style.overflow = 'hidden'
                }
                else {
                    document.getElementById('AllWindow').style.overflow = 'auto'
                }
            }
            if (mode == 'xianlutubianji') {
                document.getElementById('YinCang').hidden = true
            }
            else {
                document.getElementById('YinCang').hidden = false
            }
            modes.forEach(we890u => {
                document.getElementById(we890u).hidden = true
                document.getElementById(we890u + '1').style.color = '#777'
            });
            document.getElementById(mode).hidden = false
            document.getElementById(mode + '1').style.color = '#000'

        }
        function getRandomElement(arr) {
            if (arr.length === 0) {
                return null; // 或者抛出一个错误，数组为空
            }
            const randomIndex = Math.floor(Math.random() * arr.length);
            return arr[randomIndex];
        }
        function screenToSVG(svg, screenX, screenY) {
            var point = svg.createSVGPoint(); // 创建一个SVGPoint对象
            point.x = screenX; // 设置屏幕坐标的x值
            point.y = screenY; // 设置屏幕坐标的y值
            var matrix = svg.getScreenCTM().inverse(); // 获取屏幕坐标转换为用户坐标的反矩阵
            return point.matrixTransform(matrix); // 转换屏幕坐标为SVG内部坐标
        }
        //全局变量
        //错误提示
        var ErrorNoticesWhenSubwayNotExist = `
        这个城市的地铁可能被懵源吃了！,
        这个城市的地铁可能被懵源开走了！,
        这个城市是包头还是柳州来着？,
        哎呀，程序出bug啦！！！,
        地铁？什么是地铁？地下的铁矿石？,
        今天地铁有点不通,
        联系不上地铁公司啊！,
        今天地铁不上班，OK？,
        今天地铁客服似乎被b1b给弄独立了。。。。。。
        `.split(',')
        function RandomErrorNoticesWhenSubwayNotExist() {
            window.alert(getRandomElement(ErrorNoticesWhenSubwayNotExist))
            return getRandomElement(ErrorNoticesWhenSubwayNotExist)
        }
        var UUIDToLine = {}
        var FloatStr = `<button onclick="hide('floatLineSelect1');hiddentrue('floatStaSelect2')" class="floatingwindowcontent"
                style="z-index:100;font-size: large;color:red">X</button>选择起始线路
        </div>splitline<button onclick="hide('floatLineSelect1End');hiddentrue('floatStaSelect2End')"
                class="floatingwindowcontentEnd" style="z-index:100;font-size: large;color:red">X</button>选择终到线路
        </div>`.split('splitline')
        //生成城市选择项
        AllCityData.forEach(wye => {
            AddById('citychange', `<option value="${wye.city}">${wye.country}·${wye.city}</option>`)
        });
        //数据函数
        function FindCityByCityName(c) {
            fdc = AllCityData.find(x => x.city == c)
            if (fdc == undefined) {
                fdc = AllCityData[0]
            }
            return fdc
        }
        //所有数据
        const biaotou = `<tr>
                <td>
                    <b class="站s" style="left:0">
                        用时
                    </b>
                </td>
                <td>
                    <b class="站s">
                        路程
                    </b>
                </td>
                <td>
                    <b>

                    </b>
                </td>
                <td>
                    <b>

                    </b>
                </td>
            </tr>`;
        function IsNone(o) {
            return (o == null || o == undefined)
        }
        function GetAllStationName(DataWiki) {
            var ALLSTA = []
            DataWiki.forEach(yewwq => {
                var yewwqcolor = yewwq[1]
                var yewwqname = yewwq[0]
                for (var i = 2; i < yewwq.length; i++) {
                    st = yewwq[i]
                    if (IsNone(ALLSTA.find(x => x.name == st))) {
                        ALLSTA.push({ 'name': st, 'count': 1, 'line': [{ 'name': yewwqname, 'color': yewwqcolor }] })
                    }
                    else {

                        if (IsNone(ALLSTA.find(x => x.name == st).line.find(y => y.name == yewwqname))) {
                            ALLSTA.find(x => x.name == st).line.push({ 'name': yewwqname, 'color': yewwqcolor })
                            ALLSTA.find(x => x.name == st).count += 1
                        }
                    }
                }
            });
            return ALLSTA

        }
        function ChangeStartLable() {
            document.getElementById('local').value = document.getElementById('cfso1').value
            shiftd()
        }
        function ChangeEndLable() {
            document.getElementById('dest').value = document.getElementById('cfso1End').value
            shiftd()
        }
        function ChangeStartLableByName(nameOfs) {
            document.getElementById('local').value = nameOfs
            shiftd()
        }
        function ChangeEndLableByName(nameOfs) {
            document.getElementById('dest').value = nameOfs
            shiftd()
        }
        function SetStart() {
            document.getElementById('local').value = document.getElementById('floatingwindowPointStationName').innerHTML
            shiftd()
        }
        function SetEnd() {
            document.getElementById('dest').value = document.getElementById('floatingwindowPointStationName').innerHTML
            shiftd()
        }
        function showLineStationFloat(line2) {
            line = StrToList(line2)
            v = `<option value=" ">
          
         </option>`
            for (var i = 2; i < line.length; i++) {
                v += `<option value="${line[i]}">
         ${line[i]}
         </option>`
            }
            document.getElementById('cfs1').innerHTML = `<select onchange="ChangeStartLable()" id="cfso1">
          ${v}
        </select>`
            unhide('floatStaSelect2')
        }
        function showLineStationFloatEnd(line2) {
            line = StrToList(line2)
            v = `<option value=" ">
          
         </option>`
            for (var i = 2; i < line.length; i++) {
                v += `<option value="${line[i]}">
         ${line[i]}
         </option>`
            }
            document.getElementById('cfs1End').innerHTML = `<select onchange="ChangeEndLable()" id="cfso1End">
          ${v}
        </select>`
            unhide('floatStaSelect2End')
        }


        function hideLineStationFloat(line) {

        }
        function ListToStr(list) {
            sy = ''
            list.forEach(element => {
                sy += 'splitletter' + element
            });
            sy = sy.trim()
            return sy
        }
        function StrToList(str) {
            return str.split('splitletter').filter(x => x != [] && x.length != 0)
        }
        function rgbFromHex(hex) {
            // 将十六进制颜色转换为RGB数组
            let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
            return result ? [
                parseInt(result[1], 16),
                parseInt(result[2], 16),
                parseInt(result[3], 16)
            ] : null;
        }

        // 将RGB转换为明度
        function luminanceFromRgb(r, g, b) {
            return 0.2126 * r + 0.7152 * g + 0.0722 * b;
        }
        function CalcuateLuminance(hex) {
            rgb = rgbFromHex(hex)
            if (!hex.includes('#')) {
                rgb = hex
            }
            return luminanceFromRgb(rgb[0], rgb[1], rgb[2])
        }
        function ChooseWhiteBlack(hex) {
            lu = CalcuateLuminance(hex)
            if (lu > 160) {
                return 'black'
            }
            return 'white'
        }
        const letters = 'A B C D E F G H J K L M N P Q R S T U V W X Y Z'.split(" ")
        String.prototype.replaceAI = function (s1, s2) {
            return this.replace(new RegExp(s1, "gm"), s2);
        }
        //UUID函数
        function generateUUID(stg) {
            stg = stg.toString()
            for (var i = 0; i < 10; i++) {
                var j = i.toString()
                stg = stg.replaceAI(j, letters[i])
            }
            return stg
        }
        //数据
        function GetImgSize(id) {
            var ImgItem = document.getElementById(id)
            return { 'w': ImgItem.width, 'h': ImgItem.height }
        }
        function SpawnSelectBoard(Sname, Sx, Sy) {//点出来选择起点终点的
            var PointBarItem = document.getElementById('floatingwindowPoint')
            var PointBarNameItem = document.getElementById('floatingwindowPointStationName')
            PointBarNameItem.innerHTML = Sname
            PointBarItem.style.left = Sx + '%'
            PointBarItem.style.top = Sy * YRate / 1000 + '%'
            PointBarItem.hidden = false
        }

        function SpawnQZD(name, x, y) {
            ClearAllThisId('SpawnQZD')
            AddById('linemap', `
            <g id="SpawnQZD" class="YuanXingJk">
  <title>${name}</title>
  <rect stroke="#000" id="svg_2" height="72" width="123.99999" y="${y}" x="${x}" fill="#ffffff"/>
  <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" font-size="24" id="svg_3" y="${y + 185 - 128}" x="${x + 307 - 295}" stroke-width="0" stroke="#000" fill="green" onclick="ClearAllThisId('SpawnQZD');ChangeStartLableByName('${name}')">起点</text>
  <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" font-size="24" stroke-width="0" id="svg_4" y="${y + 186 - 128}" x="${x + 365 - 295}" stroke="#000" fill="red" onclick="ClearAllThisId('SpawnQZD');ChangeEndLableByName('${name}')">终点</text>
  <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" font-size="24" stroke-width="0" id="svg_5" y="${y + 158 - 128}" x="${x + 307 - 295}" stroke="#000" fill="darkred" onclick="ClearAllThisId('SpawnQZD');">X</text>
 </g>
            `)
        }
        function SpawnQZDReal(name, x, y) {
            ClearAllThisId('SpawnQZD')
            AddById('realmap', `
            <g id="SpawnQZD" class="YuanXingJk">
  <title>${name}</title>
  <rect stroke="#000" id="svg_2" height="72" width="123.99999" y="${y}" x="${x}" fill="#ffffff"/>
  <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" font-size="24" id="svg_3" y="${y + 185 - 128}" x="${x + 307 - 295}" stroke-width="0" stroke="#000" fill="green" onclick="ClearAllThisId('SpawnQZD');ChangeStartLableByName('${name}')">起点</text>
  <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" font-size="24" stroke-width="0" id="svg_4" y="${y + 186 - 128}" x="${x + 365 - 295}" stroke="#000" fill="red" onclick="ClearAllThisId('SpawnQZD');ChangeEndLableByName('${name}')">终点</text>
  <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" font-size="24" stroke-width="0" id="svg_5" y="${y + 158 - 128}" x="${x + 307 - 295}" stroke="#000" fill="darkred" onclick="ClearAllThisId('SpawnQZD');">X</text>
 </g>
            `)
        }
        //function SpawnEditor(name, x, y, line) {//x="305" y="209"
        //    ClearAllThisId('SpawnEditor')
        //    var spe = `<g id="SpawnEditor" class="SpawnEditor">
        //<title>${name}|${line}</title>
        // <rect stroke-width="3" stroke="#000" fill="#ffffff" x="${x + 295 - 305}" y="${y + 128 - 209}" width="333" height="118" id="svg_2"/>
        // <text  stroke="#000" fill="#bf0000" stroke-width="0" x="${x + 305 - 305}" y="${y + 209 - 209}" id="svg_3" font-size="24" font-family="Noto Sans JP" text-anchor="start" xml:space="preserve" onclick="ClearAllThisId('SpawnEditor');DeleteByNameLine('${name}','${line}')">删除</text>
        // <text  stroke="#000" fill="#000000" x="${x + 350 - 305}" y="${y + 163 - 209}" id="svg_4" stroke-width="0" font-size="24" font-family="Noto Sans JP" text-anchor="start" xml:space="preserve" onclick="ClearAllThisId('SpawnEditor')">${name}|${line}</text>
        // <text stroke="#000" fill="#ff0000" x="${x + 305 - 305}" y="${y + 156 - 209}" id="svg_5" stroke-width="0" font-size="24" font-family="Noto Sans JP" text-anchor="start" xml:space="preserve" onclick="ClearAllThisId('SpawnEditor')">X</text>
        //</g>`
        // A//ddById('linemapedit', spe)
        //}
        function DeleteByNameLine(name, line) {
            if (CtrlKey) {
                ClearAllThisClassInclude(name + '|' + line)
            }
            ShuaXinYouCe()
            ReloadStationNotHavePosition()
        }
        //O
        function Circle(x, y, r, color, opacity, id, class2, onclick2) {
            colorr = ''
            if (color != '') {
                colorr = `fill="${color}"`
            }
            return `<circle
  cx="${x}"      
  cy="${y}"     
  r="${r}"            
        ${colorr}
  fill-opacity="${opacity}"  
  id="${id}"
  class="${class2}"
  title="${class2}"
  onclick="${onclick2}"
/>`

        }
        function GetAllPositionDataOfSubwayMap() {
            var allpc = FindAllThisId('EditorCircle')
            var AllpcitemP = []
            allpc.forEach(pcitem => {
                NandL = pcitem.getAttribute('class').split('|')
                pcitemName = NandL[0]
                pcitemLine = NandL[1]
                AllpcitemP.push({ 'x': parseInt(pcitem.getAttribute('cx')), 'y': parseInt(pcitem.getAttribute('cy')), 'name': pcitemName, 'line': pcitemLine, 'color': '' })
            });
            return AllpcitemP
        }
        function GetAllMiddleWayDataOfSubwayMap() {
            var allpc = FindAllThisId('MiddleWayCircle')
            var AllpcitemP2 = []
            allpc.forEach(pcitem2 => {
                classsp = pcitem2.getAttribute('class').split('|')
                Name1 = classsp[0]
                Line1 = classsp[1]
                Name2 = classsp[2]
                Line2 = classsp[3]
                MWIdex = parseInt(classsp[4])
                AllpcitemP2.push({ 'x': parseInt(pcitem2.getAttribute('cx')), 'y': parseInt(pcitem2.getAttribute('cy')), 'name1': Name1, 'name2': Name2, 'line1': Line1, 'line2': Line2, 'mwindex': MWIdex, 'color': GetColorByLineName(Line1) })

            });
            return AllpcitemP2
        }
        function SetStartIcon(x, y) {
            AddById('linemap', `
            
            `)
        }
        //1
        function LineD(x1, x2, y1, y2, color, width, opacity, id, class2) {
            return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}"
            style="stroke:${color};stroke-width:${width};stroke-opacity:${opacity}" class="${class2}" id="${id}" />`
        }
        function reloadmap() {
            cityn = document.getElementById('citychange').value
            ThisCity = FindCityByCityName(cityn)
            var linedata = ThisCity.lineweb
            if (linedata == [] || linedata.length == 0) {
                WriteById('notices', RandomErrorNoticesWhenSubwayNotExist())
                return;
            }
            else {
                ClearById('notices')
            }
            //站列表
            var ALLSTAS = GetAllStationName(linedata).sort((a, b) => {
                if (a.count != b.count) {
                    return -a.count + b.count
                }
                return a.name.localeCompare(b.name)
            })
            //渲染站列表
            ZhanLieBiao = '<h2>所有车站</h2><table><tbody>'
            ALLSTAS.forEach(STASItem => {
                var STASItemLines = STASItem.line.sort((a, b) => {
                    if (a.name.includes('号线') && b.name.includes('号线')) {
                        return parseInt(findNumberBeforeStr(a.name)) - parseInt(findNumberBeforeStr(b.name))
                    }
                    else if (a.name.includes('号线') && false == b.name.includes('号线')) {
                        return -1
                    }
                    else if (b.name.includes('号线') && false == a.name.includes('号线')) {
                        return 1
                    }
                    return a.name.localeCompare(b.name)
                })
                ZhanLieBiao += `
                <tr><td>${STASItem.name}</td>
                `
                STASItemLines.forEach(STASItemLinesItem => {
                    ZhanLieBiao += `
                    <td style="background-color:${STASItemLinesItem.color};color:${ChooseWhiteBlack(STASItemLinesItem.color)}">${STASItemLinesItem.name}</td>
                    `
                });
                ZhanLieBiao += '</tr>'
            });
            ZhanLieBiao += '</tbody></table>'
            WriteById('chezhan', ZhanLieBiao)
            //渲染线路表格
            XianLieBiao = '<h2>所有线路</h2><table><tbody>';
            linedata.forEach(LDItem => {
                XianLieBiao += `<tr><td style="color:${ChooseWhiteBlack(LDItem[1])};background-color:${LDItem[1]}">${LDItem[0]}</td>`
                for (var syasuw = 2; syasuw < LDItem.length; syasuw++) {
                    XianLieBiao += `<td>${LDItem[syasuw]}</td>`
                }
                XianLieBiao += `</tr>`
            });
            XianLieBiao += '</tbody></table>'
            WriteById('xianlu', XianLieBiao)
            //获取尺寸
            // 创建canvasconst 

            //渲染线路图
            if (ThisCity.subwaymap.includes('<')) {
                WriteById('linemap', ThisCity.subwaymap)
                WriteById('linemapedit', ThisCity.subwaymap)
            }
            else {
                WriteById('linemap', `<image xlink:href="${ThisCity.subwaymap}">`)
                WriteById('linemapedit', `<image xlink:href="${ThisCity.subwaymap}">`)
            }
            if (ThisCity.realmap.includes('<')) {
                WriteById('realmap', ThisCity.realmap)
            }
            else {
                WriteById('realmap', `<image xlink:href="${ThisCity.realmap}">`)
            }


            //渲染编辑器
            var LineMapPointsEdit = ``
            var LineMapPointsReal = ''
            if (ThisCity.stationdata.length != 0) {
                //生成线路图的点
                var LineMapPoints = ``

                ThisCity.realposition.forEach(RealPositionData => {
                    LineMapPointsReal += `<circle
  cx="${RealPositionData.x}"      
  cy="${RealPositionData.y}"     
  r="${ThisCity.realmapData.stationR}"            
  fill="red"      
  fill-opacity="0"  
  id="YuanXingJk"
  class="YuanXingJk"
  onclick="SpawnQZDReal('${RealPositionData.name}', ${RealPositionData.x}, ${RealPositionData.y})"
/>`
                })
                ThisCity.stationdata.forEach(StationItemData => {
                    LineMapPoints += `<circle
  cx="${StationItemData.x}"      
  cy="${StationItemData.y}"     
  r="${ThisCity.subwaymapData.stationR}"            
  fill="red"      
  fill-opacity="0"  
  id="YuanXingJk"
  class="YuanXingJk"
  onclick="SpawnQZD('${StationItemData.name}', ${StationItemData.x}, ${StationItemData.y})"
/>`

                    LineMapPointsEdit += `<circle
  cx="${StationItemData.x}"      
  cy="${StationItemData.y}"     
  r="${ThisCity.subwaymapData.stationR / 2}"            
  fill="orange"      
  fill-opacity="0.8"  
  id="EditorCircle"
  line="${StationItemData.line}"
  class="${StationItemData.name}|${StationItemData.line}"
  oncontextmenu="DeleteByNameLine('${StationItemData.name}','${StationItemData.line}')"
  onmousedown="CircleMoveDown('${StationItemData.name}|${StationItemData.line}')"
  onmouseup="CircleMoveUp('${StationItemData.name}|${StationItemData.line}')"
  isDragging=false
><title>${StationItemData.name}|${StationItemData.line}</title></circle>`
                });
                ThisCity.stationMiddleWayData.forEach(MDW => {
                    cls = `${MDW.name1}|${MDW.line1}|${MDW.name2}|${MDW.line2}|${MDW.mwindex}`
                    LineMapPointsEdit += `<circle
  cx="${MDW.x}"      
  cy="${MDW.y}"     
  r="${ThisCity.subwaymapData.stationR / 3.2}"            
  fill="red"      
  fill-opacity="0.7"  
  id="MiddleWayCircle"
  line="${MDW.line}"
  class="${cls}"
  oncontextmenu="ClearAllThisClass('${cls}')"
  onmousedown="CircleMoveDown('${MDW.name1}|${MDW.line1}|${MDW.name2}|${MDW.line2}|${MDW.mwindex}')"
  onmouseup="CircleMoveUp('${MDW.name1}|${MDW.line1}|${MDW.name2}|${MDW.line2}|${MDW.mwindex}')"
  isDragging=false
><title>${MDW.name1}|${MDW.line1}|${MDW.name2}|${MDW.line2}|${MDW.mwindex}</title></circle>`
                });
                ReloadStationNotHavePosition()
                AddById('linemap', LineMapPoints)
                AddById('linemapedit', LineMapPointsEdit)
                AddById('realmap', LineMapPointsReal)
                //生成LineEditColor的css
                var LineEditColors = ''
                linedata.forEach(linedatac => {
                    LineEditColors += `circle[line='${linedatac[0]}']{fill:'${linedatac[1]}'}`
                });
                WriteById('EditLineColor', LineEditColors)
            }

            //生成顶部选择框
            var e11 = ''
            for (var y = 0; y < linedata.length; y++) {
                e9 = linedata[y]
                if (y % 3 == 0) {
                    e11 += `<tr><td style="background-color:${e9[1]};text-align:center;color:${ChooseWhiteBlack(e9[1])} " onclick="showLineStationFloat('${ListToStr(e9)}')" onmouseleave="hideLineStationFloat('${ListToStr(e9)}')">
                ${e9[0]}
                </td>`
                }
                else if (y % 3 == 1) {
                    e11 += `<td style="background-color:${e9[1]};text-align:center;color:${ChooseWhiteBlack(e9[1])} " onclick="showLineStationFloat('${ListToStr(e9)}')" onmouseleave="hideLineStationFloat('${ListToStr(e9)}')">
                ${e9[0]}
                </td>`
                }
                else if (y % 3 == 2) {
                    e11 += `<td style="background-color:${e9[1]};text-align:center;color:${ChooseWhiteBlack(e9[1])} " onclick="showLineStationFloat('${ListToStr(e9)}')" onmouseleave="hideLineStationFloat('${ListToStr(e9)}')">
                ${e9[0]}
                </td></tr>`
                }

            }
            var e10 = `
                <table style="text-align:center">
                    ${e11}
                    </table>`
            document.getElementById('floatLineSelect1d').innerHTML = FloatStr[0] + e10

            //生成顶部选择框End
            var e11 = ``
            for (var y = 0; y < linedata.length; y++) {
                e9 = linedata[y]
                if (y % 3 == 0) {
                    e11 += `<tr><td style="background-color:${e9[1]};text-align:center;color:${ChooseWhiteBlack(e9[1])} " onclick="showLineStationFloatEnd('${ListToStr(e9)}')" onmouseleave="hideLineStationFloat('${ListToStr(e9)}')">
                ${e9[0]}
                </td>`
                }
                else if (y % 3 == 1) {
                    e11 += `<td style="background-color:${e9[1]};text-align:center;color:${ChooseWhiteBlack(e9[1])} " onclick="showLineStationFloatEnd('${ListToStr(e9)}')" onmouseleave="hideLineStationFloat('${ListToStr(e9)}')">
                ${e9[0]}
                </td>`
                }
                else if (y % 3 == 2) {
                    e11 += `<td style="background-color:${e9[1]};text-align:center;color:${ChooseWhiteBlack(e9[1])} " onclick="showLineStationFloatEnd('${ListToStr(e9)}')" onmouseleave="hideLineStationFloat('${ListToStr(e9)}')">
                ${e9[0]}
                </td></tr>`
                }

            }
            var e10 = `
                <table style="text-align:center">
                    ${e11}
                    </table>`
            document.getElementById('floatLineSelect1dEnd').innerHTML = FloatStr[1] + e10
            //数据处理
            var LindAndUUID = {}
            UUIDToLine = {}
            for (var iq = 0; iq < linedata.length; iq++) {
                LindAndUUID[linedata[iq]] = generateUUID(iq) + iq.toString()
                UUIDToLine[generateUUID(iq) + iq.toString()] = linedata[iq]
            }
            for (var i1 = 0; i1 < linedata.length; i1++) {
                var e1 = linedata[i1]
                linename = e1[0]
                lineUUID = LindAndUUID[linedata[i1]]
                linecolor = e1[1]
                LinePyData = ThisCity.linedata.find(x => x.name == linedata[i1][0])
                if (LinePyData == undefined && linedata[i1][0].includes('支线')) {
                    LinePyData = ThisCity.linedata.find(x => x.name + '支线' == linedata[i1][0])
                }
                for (var i = 2; i < e1.length; i++) {
                    st = e1[i]
                    var linkS = []
                    if (i != e1.length - 1) {
                        //非终点站
                        var directNext = e1[e1.length - 1]
                        //环线
                        if (e1[2] == e1[e1.length - 1]) {
                            directNext = '环线下一站'
                        }
                        Dsts = CalcuateStationDistance(st, e1[i + 1], linedata[i1][0])
                        tm = CalcuateTimeByDistance(Dsts * 1000, LinePyData.v, LinePyData.a, 35)
                        linkS.push({
                            name: e1[i + 1] + lineUUID,
                            weight: tm,
                            type: 'line',
                            line: lineUUID,
                            from: st + lineUUID,
                            direct: directNext,
                            time: tm,
                            distance: Dsts
                        })
                    }
                    if (i != 2) {
                        //非第一个站
                        var directNext = e1[2]
                        //环线
                        if (e1[2] == e1[e1.length - 1]) {
                            directNext = '环线上一站'
                        }
                        Dsts = CalcuateStationDistance(st, e1[i - 1], linedata[i1][0])
                        tm = CalcuateTimeByDistance(Dsts * 1000, LinePyData.v, LinePyData.a, 35)
                        linkS.push({
                            name: e1[i - 1] + lineUUID,
                            weight: 200,
                            type: 'line',
                            line: lineUUID,
                            from: st + lineUUID,
                            direct: directNext,
                            time: tm,
                            distance: Dsts
                        })
                    }
                    linkS.push({
                        name: st + 'endnode',
                        weight: 0,
                        type: 'end',
                        line: -2,
                        from: st + lineUUID
                    })
                    var StationItem = { RealName: st, name: st + lineUUID, links: linkS }
                    NewData.push(StationItem)
                    //创建唯一endnode
                    var uniqueendnode = NewData.find(x => x.name == st + 'endnode')
                    if (uniqueendnode == null || uniqueendnode == undefined) {
                        var unq = {
                            RealName: st, name: st + 'endnode', links: []
                        }
                        NewData.push(unq)
                    }
                }
            }
            //换乘计算
            for (var i = 0; i < NewData.length; i++) {
                st = NewData[i]
                nm = st.name
                if (!nm.includes('endnode')) {
                    rm = st.RealName
                    StationHaveSameName = NewData.filter(x => x.RealName == rm && x.name != nm && x.name.includes('endnode') == false)
                    if (StationHaveSameName != undefined && StationHaveSameName != null) {
                        StationHaveSameName.forEach(e5 => {
                            //FirstP= FindXYbyNameLine(st.RealName, FindLineByUUID(st.line))
                            //SecondP=FindXYbyNameLine(e5.RealName,FindLineByUUID(e5.line))
                            Dsts = 100
                            //Dsts = CalcuateDistance(FirstP.x,SecondP.x,FirstP.y,SecondP.y)
                            var addtrans = {
                                name: e5.name,
                                weight: Dsts * 2,
                                type: 'transfer',
                                line: 0,
                                from: nm,
                                time: Dsts,
                                distance: Dsts
                            }
                            if (!NewData[i].links.includes(addtrans))
                                NewData[i].links.push(addtrans)
                        });
                    }
                }

            }
            //刷新没有位置的站
            ReloadStationNotHavePosition()
        }
        function ReloadZhanju() {
            LineDataTable = ''
            lw = LineNameSortLineWeb(ThisCity.lineweb)
            lw = LineNameSortLineWeb(lw)
            lw.forEach(lwb => {
                LineDataTable += CalcuateLineDataToATable(lwb[0])
            });
            WriteById('zhanju', LineDataTable)
        }
        function ReloadStationNotHavePosition() {
            var StationThatNotHavePosition2 = FindStationThatNotHavePosition()
            if (StationThatNotHavePosition2.length != 0) {
                WriteById('ticizhan', StationThatNotHavePosition2[0].name)
                WriteById('ticixian', StationThatNotHavePosition2[0].line)
                document.getElementById('ticise').style.backgroundColor = GetColorByLineName(StationThatNotHavePosition2[0].line)
                document.getElementById('ticise').style.color = GetColorByLineName(StationThatNotHavePosition2[0].line)
            }
        }

        //先刷新一下
        reloadmap()
        function CheckName(nodeu) {
            if (nodeu.type == 'line') {
                if (!nodeu.name.includes(nodeu.line)) {
                    nodeu.name += nodeu.line
                }
                if (!nodeu.from.includes(nodeu.line)) {
                    nodeu.from += nodeu.line
                }
            }
            return nodeu
        }
        // Dijkstra 算法
        class Queue {
            constructor() {
                this.items = [];
            }
            // 入列
            enqueue(element) {
                this.items.push(element);
            }
            // 判断队列是否为空
            isEmpty() {
                return this.items.length === 0;
            }
        }
        // node
        const nodes = NewData
        class Dijkstra {
            constructor(nodes, start, end) {
                this.nodes = nodes; // 节点
                this.start = start; // 起点
                this.end = end; // 终点
                this.flow = []; // 最优路径
                this.queue = new Queue(); // 队列
                this.minDistance = Infinity;
            }

            // 计算最优路径
            calcuate() {
                this.flow = []
                // 初始化队列
                for (const node of this.nodes) {
                    this.queue.enqueue({
                        name: node.name,
                        distance: this.start === node.name ? 0 : Infinity,
                        isChecked: false,
                        lastNode: null,
                        links: node.links
                    })

                }
                // 计算距离start地点的distance
                while (this.queue.items.some(item => !item.isChecked)) {
                    const tempList = this.queue.items.filter(item => !item.isChecked).sort((a, b) => a.distance - b.distance)
                    tempList[0].isChecked = true
                    tempList[0].links.forEach(link => {
                        if (!this.queue.items.filter(item => item.isChecked).find(item => item.name === link.name)) {
                            const index = this.queue.items.findIndex(value => link.name === value.name)
                            const _distance = link.weight + tempList[0].distance
                            if (this.queue.items[index].distance > _distance) {
                                this.queue.items[index].distance = link.weight + tempList[0].distance
                                this.queue.items[index].lastNode = tempList[0].name
                            }
                        }
                    })
                }

                this.flow.unshift(this.end)
                // 找到目的地后追溯至起点
                while (this.flow[0]) {
                    const lastNode = this.queue.items.find(item => this.flow[0] === item.name)
                    if (this.flow.length === 1) this.minDistance = lastNode.distance
                    this.flow.unshift(lastNode ? lastNode.lastNode : null)
                }
                this.flow.shift()
                return this.flow.join('->')
            }
        }
        //
        function findStationUUID(n) {
            var aw = NewData.find(x => x.RealName == n)
            if (aw != undefined && aw != null) {
                var ret = aw.name
                return ret
            }
        }
        function findStationByUUID(n) {
            var aw = NewData.find(x => x.name == n)
            if (aw != undefined && aw != null) {
                var ret = aw.RealName
                return ret
            }
        }
        function BreakWall(listl) {
            listr = []
            listl.forEach(lpo => {
                lpo.forEach(sqw => {
                    listr.push(sqw)
                });
            });
            return listr
        }
        function PathExplainerF(p, startn) {
            var newweb = nodes
            newweb.push(startn)
            var pathe = p.split('->')
            var newp = []
            var AllLinks = BreakWall(newweb.map(x => x.links))
            for (var i = 0; i < pathe.length - 1; i++) {
                var ThisSt = pathe[i]
                var NextSt = pathe[i + 1]
                var ThisPathe = AllLinks.find(x => x.from == ThisSt && x.name == NextSt)
                var newThisPathe = {
                    name: findStationByUUID(ThisPathe.name),
                    weight: ThisPathe.weight,
                    type: ThisPathe.type,
                    line: ThisPathe.line,
                    from: findStationByUUID(ThisPathe.from),
                    direct: ThisPathe.direct,
                    time: ThisPathe.time,
                    distance: ThisPathe.distance
                }
                newp.push(newThisPathe)
            }
            return newp
        }
        function ClearAllThisId(id) {
            // 查询所有div
            const allDivs = document.querySelectorAll(`[id="${id}"]`);

            // 遍历所有div
            allDivs.forEach(function (div) {
                // 检查id是否以"remove-"开头
                if (div.id == id) {
                    // 如果是，则删除该div
                    div.remove();
                }
            });
        }
        function ClearAllThisClass(id) {
            // 查询所有div
            const allDivs = FindAllThisClass(id)
            // 遍历所有div
            allDivs.forEach(function (div) {
                // 检查id是否以"remove-"开头
                // 如果是，则删除该div
                div.remove();

            });
        }
        function ClearAllThisClassInclude(id) {
            // 查询所有div
            const allDivs = FindAllThisClassInclude(id)
            // 遍历所有div
            allDivs.forEach(function (div) {
                // 检查id是否以"remove-"开头
                // 如果是，则删除该div
                div.remove();

            });
        }
        function FindAllThisId(id) {
            // 查询所有div
            const allDivs = document.querySelectorAll(`[id="${id}"]`);
            return allDivs
        }
        function FindAllThisClass(id) {
            // 查询所有div
            const allDivs = document.querySelectorAll(`[class="${id}"]`);
            return allDivs
        }
        function FindAllThisClassInclude(id) {
            // 查询所有div
            const allDivs = document.querySelectorAll(`[class*="${id}"]`);
            return allDivs
        }
        function FindOneThisClass(id) {
            return FindAllThisClass(id)[0]
        }
        function FindOneThisId(id) {
            return FindAllThisId(id)[0]
        }
        function ReloadAll() {
            ClearAllThisId('SpawnEditor')
            ClearAllThisId('LianXian')
            ClearAllThisId('StartNodeItemCss')
            ClearAllThisId('EndNodeItemCss')
            ClearAllThisId('JianTing2')
            ClearAllThisId('SpawnQZD')
            ClearAllThisId('StartNodeItemSvg')
            ClearAllThisId('EndNodeItemSvg')
            ClearAllThisId('JianTing2')
        }
        function shiftd() {
            ClearAllThisId('LianXian')
            ClearAllThisId('StartNodeItemCss')
            ClearAllThisId('EndNodeItemCss')
            ClearAllThisId('JianTing2')
            var newnodes = ''
            newnodes = NewData
            start = document.getElementById('local').value
            end = document.getElementById('dest').value
            starts = findStationUUID(start)
            ends = findStationUUID(end)
            //取消上一次的
            newnodes = newnodes.filter(x => x.name != start + 'startnode')
            //起点确定
            var startnodes = newnodes.map(node => [node.RealName, node.name]).filter(x => x[0] == start && x[1] != start + 'startnode' && x[1] != end + 'endnode')
            var startnodelinks = []
            startnodes.forEach(e6 => {
                startnodelinks.push({
                    name: e6[1],
                    weight: 0,
                    type: 'start',
                    line: -1,
                    from: start + 'startnode'
                })
            });
            startnode = {
                RealName: start,
                name: start + 'startnode',
                links: startnodelinks
            }
            newnodes.push(startnode)
            //
            //
            const names = newnodes.map(node => node.name)
            if (!names.includes(starts) || !names.includes(ends)) return

            const dijkstraObject = new Dijkstra(newnodes, start + 'startnode', end + 'endnode')
            const minPath = dijkstraObject.calcuate()
            var expedPath = PathExplainerF(minPath, startnode)
            document.getElementById('tablere').innerHTML = biaotou
            ShowPath(expedPath)
        }
        function IsListEmpty(list2) {
            return (list2 == [] || list2.length == 0)
        }
        //数学区
        function VKmHToMS(v) {
            return v * 1000 / 3600
        }
        function VMSToKmH(v) {
            return v * 3.6
        }
        function CalcuateTime(x1, x2, y1, y2, Vmax, a, Tstop) {
            Vmax = VKmHToMS(Vmax)
            var t = Tstop
            var x = CalcuateDistance(x1, x2, y1, y2)
            var xSpeedUp = 0.5 * (Vmax ** 2) / a
            if (0.5 * x <= xSpeedUp) {
                //不足以加速到最大速度
                t += 2 * (Math.sqrt(x / a))
            }
            else {
                //包含最大速度了
                t += 2 * (Vmax / a) + (x - 2 * xSpeedUp) / Vmax
            }
            return t
        }
        function CalcuateTimeByDistance(d, Vmax, a, Tstop) {
            Vmax = VKmHToMS(Vmax)
            var t = Tstop
            var x = d
            var xSpeedUp = 0.5 * (Vmax ** 2) / a
            if (0.5 * x <= xSpeedUp) {
                //不足以加速到最大速度
                t += 2 * (Math.sqrt(x / a))
            }
            else {
                //包含最大速度了
                t += 2 * (Vmax / a) + (x - 2 * xSpeedUp) / Vmax
            }
            return t
        }
        function CalcuateCost(x1, x2, y1, y2, CostPerKm) {
            var x = CalcuateDistance(x1, x2, y1, y2)
            return CostPerKm * x / 1000
        }
        function CalcuateCostByFunction(x1, x2, y1, y2, f) {
            var x = CalcuateDistance(x1, x2, y1, y2).toString()
            var f1 = f.replaceAI('x', x)
            return eval(f1)//例如，2**x+5x**2+2，不要有y/f(x)，暂不支持求导
        }
        //根据两点坐标计算连线偏转角
        function CalcuateAngle(x1, x2, y1, y2) {
            var tancita = (y1 - y2) / (x1 - x2)
            return Math.atan(tancita)
        }
        //计算直线
        function CalcuateLine(x1, x2, y1, y2) {
            return { 'd': CalcuateDistance(x1, x2, y1, y2), 'a': CalcuateAngle(x1, x2, y1, y2) }
        }
        //计算站距
        function FindXYbyNameLine(n, l) {
            return ThisCity.stationdata.find(x => x.name == n && x.line == l)
        }
        function FindXYbyNameLineRealmap(n, l) {
            return ThisCity.realposition.find(x => x.name == n && x.line == l)
        }

        //数学区
        //基础区
        function print(a) {
            console.log(a)
        }
        function FindLineByUUID(u) {
            uq = UUIDToLine[u]
            if (uq == undefined) {
                return u
            }
            return UUIDToLine[u]
        }
        function FindStationThatNotHavePosition() {
            var datawiki = ThisCity.lineweb
            var stationpositions = GetAllPositionDataOfSubwayMap()
            var NoPositionSta = []
            datawiki.forEach(datawikiline => {
                for (var i = 2; i < datawikiline.length; i++) {
                    datawikistation = datawikiline[i]
                    if (stationpositions.filter(x => x.name == datawikistation && x.line == datawikiline[0]).length == 0) {
                        //没有位置
                        NoPositionSta.push({ 'line': datawikiline[0], 'name': datawikistation })
                    }
                };
            });
            return NoPositionSta
        }
        //基础区
        //隐藏区
        function hide(id) {
            if (document.getElementById(id).hidden == true) {
                document.getElementById(id).hidden = false
            }
            else {
                document.getElementById(id).hidden = true
            }
        }
        function unhide(id) {
            if (document.getElementById(id).hidden == true) {
                document.getElementById(id).hidden = false
            }
        }
        function hiddentrue(id) {
            if (document.getElementById(id).hidden == false) {
                document.getElementById(id).hidden = true
            }
        }
        //隐藏区
        //显示路径规划
        function ShowPath(Path2) {

            var LineMapPoint2s = ``
            SumTime = 0
            SumDistance = 0
            var IndexNum = 0//第几行
            var aTr = ''
            var Pathr = Path2.filter(x => x.type == 'line')
            Pathr.forEach(phy => {
                phy.line = FindLineByUUID(phy.line)
            });
            var HiddenBar = []//管辖范围归零
            for (var u = 0; u < Pathr.length; u++) {
                p = (Pathr[u])
                var TheLineId = p.line
                if (TheLineId != 0 && TheLineId != -1 && TheLineId != -2) {
                    var TheLine = FindLineByUUID(p.line)
                    var LineAndDirect = `${TheLine[0]}(开往 ${p.direct})`
                    var LineAndDirectLast = ''
                    //显示数据初始化
                    var LAD = LineAndDirect
                    var FROM = p.from
                    var transText = '换乘'
                    var TheLineColor = TheLine[1]
                    var CircleColor = '#eee'
                    var CircleClassName = '圆形'
                    var TRClassName = 'normalSt'
                    //显示数据初始化
                    if (u != 0) {
                        LineAndDirectLast = `${FindLineByUUID(Pathr[u - 1].line)[0]}(开往 ${Pathr[u - 1].direct})`
                    }
                    else {
                        transText = '乘车'
                        CircleClassName = '方形'
                    }
                    if (LineAndDirect != LineAndDirectLast && ThisCity.stationdata.length != 0) {
                        if (u != 0) {
                            LineMapPoint2s += Circle(FindXYbyName(p.from).x, FindXYbyName(p.from).y,
                                ThisCity.subwaymapData.stationR / 1.2, 'orange', 0.824, 'JianTing2', 'yxjk', '')
                        }
                        aTr = `
                    <tr class="${TRClassName}" id="${'teshuzhan' + IndexNum}">
                        <td class="站s">
                            ${convertSecondsToHMS(SumTime)}
                        </td>
                        <td class="站s">
                            ${SumDistance/10}
                        </td>
                        <td class="tdjx">
                            <div class="juxing" style="background-color: ${TheLineColor};" title="${LAD}">
                                <div class="${CircleClassName}" title="${FROM}" style="background-color:${CircleColor}"></div>
                            </div>
                        </td>
                        <td>
                            <span class="站">
                                <span class="换乘文本">${transText} </span>
                                <a style="color:#333333" class="换乘文本">${LAD}</a>
                                <br>
                                <span class="链接站" >
                                        ${FROM}
                                </span>

                            </span>
                        </td>
                    </tr>
                    `
                        if (HiddenBar != [] && HiddenBar.length != 0) {
                            document.getElementById('teshuzhan' + (HiddenBar[0] - 1)).onclick = 1
                            document.getElementById('teshuzhan' + (HiddenBar[0] - 1)).onclick = `hideall(${HiddenBar[0]},${HiddenBar[HiddenBar.length - 1]})`
                        }
                        HiddenBar = []//管辖范围归零
                    }
                    else {
                        if (u == Pathr.length) {
                            TheLineColor = 'white'
                            if (HiddenBar != [] && HiddenBar.length != 0) {
                                document.getElementById('teshuzhan' + (HiddenBar[0] - 1)).onclick = `hideall(${HiddenBar[0]},${HiddenBar[HiddenBar.length - 1]})`
                            }
                            HiddenBar = []//管辖范围归零
                        }
                        else {
                            CircleClassName = '普通站'
                            TRClassName = '中途站' + IndexNum
                            HiddenBar.push(IndexNum)
                        }
                        if (u != 0 && ThisCity.stationdata.length != 0) {
                            LineMapPoint2s += Circle(FindXYbyName(p.from).x, FindXYbyName(p.from).y,
                                ThisCity.subwaymapData.stationR / 1.9, 'orange', 0.75, 'JianTing2', 'yxjk', '')
                        }
                        aTr = `<tr class="${TRClassName}">
                            <td class="站s">
                            ${convertSecondsToHMS(SumTime) }
                        </td>
                        <td class="站s">
                            ${SumDistance /10}
                        </td>
                            <td class="tdjx">
                                    <div class="juxing" style="background-color: ${TheLineColor};" title="${LAD}">
                                            <div class="${CircleClassName}" title="${FROM}" ></div>
                                    </div>
                            </td>
                            <td>
                                <span class="站">
                                    <a class="链接站" >
                                        ${FROM}
                                        </a>
                                </span>
                            </td>
                        </tr>`
                    }

                    SumTime += p.time
                    SumDistance += parseInt(p.distance * 10)
                    IndexNum += 1
                    document.getElementById('tablere').innerHTML += aTr
                }

            }
            //最后一个站
            TheLineColor = 'white'
            CircleClassName = '方形'
            HiddenBar = []//管辖范围归零
            aTr = `<tr class="${TRClassName}">
                            <td class="站s">
                            ${convertSecondsToHMS(SumTime)}
                        </td>
                        <td class="站s">
                            ${SumDistance/10}
                        </td>
                            <td class="tdjx">
                                    <div class="juxing" style="background-color: ${TheLineColor};" title="${LAD}">
                                            <div class="${CircleClassName}" title="${FROM}" ></div>
                                    </div>
                            </td>
                            <td>
                                <span class="站">
                                    <a class="链接站" >
                                        ${Pathr[Pathr.length - 1].name}
                                        </a>
                                </span>
                            </td>
                        </tr>`
            document.getElementById('tablere').innerHTML += aTr
            //下面写连接线（变形图）
            if (!IsListEmpty(ThisCity.stationdata)) {
                LineMapPoint2s += Circle(FindXYbyName(Pathr[0].from).x, FindXYbyName(Pathr[0].from).y,
                    ThisCity.subwaymapData.stationR / 1.2, 'green', 0.75, 'JianTing2', 'yxjk', '')
                PolyLineAllPoints = `${FindXYbyName(Pathr[0].from).x},${FindXYbyName(Pathr[0].from).y} `
                for (var piu = 0; piu < Pathr.length; piu++) {
                    var MiddleWays = FindMiddleWay(Pathr[piu].from, FindLineByUUID(Pathr[piu].line)[0], Pathr[piu].name, FindLineByUUID(Pathr[piu].line)[0])
                    if (MiddleWays.length != 0) {
                        MiddleWays.forEach(MiddleWayItem => {
                            PolyLineAllPoints += `${MiddleWayItem.x},${MiddleWayItem.y} `
                        });
                    }
                    PolyLineAllPoints += `${FindXYbyName(Pathr[piu].name).x},${FindXYbyName(Pathr[piu].name).y} `

                }
                AddById('linemap', `<polyline points="${PolyLineAllPoints}" id="LianXian" style="fill:none;stroke:black;stroke-width:${ThisCity.subwaymapData.stationR / 1.3};opacity:0.8"/>`)
                LineMapPoint2s += Circle(FindXYbyName(Pathr[Pathr.length - 1].name).x, FindXYbyName(Pathr[Pathr.length - 1].name).y,
                    ThisCity.subwaymapData.stationR / 1.2, 'red', 0.75, 'JianTing2', 'yxjk', '')
            }
            AddById('linemap', LineMapPoint2s)
            //下面写连接线（地图）
            PolyLineAllPoints = ''
            if (!IsListEmpty(ThisCity.realposition)) {
                var xys = FindXYbyNameLineRealmap(Pathr[0].from, Pathr[0].line[0])
                var xyl = FindXYbyNameLineRealmap(Pathr[Pathr.length - 1].name, Pathr[Pathr.length - 1].line[0])
                LineMapPoint2s += Circle(xys.x, xys.y,
                    ThisCity.realposition.stationR / 1.2, 'green', 0.75, 'JianTing2', 'yxjk', '')
                PolyLineAllPoints = `${xys.x},${xys.y} `
                for (var piu = 0; piu < Pathr.length; piu++) {
                    var xyn = FindXYbyNameLineRealmap(Pathr[piu].name, Pathr[0].line[0])
                    PolyLineAllPoints += `${FindXYbyNameLineRealmap(Pathr[piu].from,Pathr[piu].line[0]).x},${FindXYbyNameLineRealmap(Pathr[piu].from, Pathr[piu].line[0]).y} `
                    
                    if (IsABStation(Pathr[piu].from, FindLineByUUID(Pathr[piu].line)[0], Pathr[piu].name, FindLineByUUID(Pathr[piu].line)[0])) {
                        var MiddleWays = FindMiddleWayRealmap(Pathr[piu].from, FindLineByUUID(Pathr[piu].line)[0], Pathr[piu].name, FindLineByUUID(Pathr[piu].line)[0])
                        if (MiddleWays.length != 0) {
                            MiddleWays.forEach(MiddleWayItem => {
                                PolyLineAllPoints += `${MiddleWayItem.x},${MiddleWayItem.y} `
                            });
                        }
                    }
                        
                    if (xyn != undefined) {
                        PolyLineAllPoints += `${xyn.x},${xyn.y} `
                    }
                }
                PolyLineAllPoints+=`${xyl.x},${xyl.y} `
                AddById('realmap', `<polyline points="${PolyLineAllPoints}" id="LianXian" style="fill:none;stroke:black;stroke-width:${ThisCity.realmapData.stationR / 2};opacity:0.8"/>`)
                //LineMapPoint2s += Circle(xyl.x, xyl.y,
                //    ThisCity.realmapData.stationR / 1.2, 'red', 0.75, 'JianTing2', 'yxjk', '')
            }
            // AddById('realmap', LineMapPoint2s)
        }
        function FindXYbyName(nf) {
            var nsau = ThisCity.stationdata.find(z => z.name == nf)
            return nsau
        }
        function hideall(fr, to) {
            for (var i = fr; i < to + 1; i++) {
                if (document.getElementById('中途站' + i).hidden != true) {
                    document.getElementById('中途站' + i).hidden = true
                }
                else {
                    document.getElementById('中途站' + i).hidden = false
                }

            }
        }
        function WriteById(id, wr) {
            document.getElementById(id).innerHTML = wr
        }
        function AddById(id, wr) {
            document.getElementById(id).innerHTML += wr
        }
        function ClearById(id) {
            document.getElementById(id).innerHTML = ''
        }
    </script>
    <script>
        const margin = 50; // 设置一个边缘距离
        const windowWidth = window.innerWidth;
        const windowHeight = window.innerHeight;
        const danwei = 25
        const updowndanwei = 200
        function VB() {
            return ParseToIntList(document.getElementById('linemap').getAttribute('viewBox').split(' '));
        }
        function West() {
            var vb = VB()
            vb[0] += -danwei
            SetVB(vb)
        }
        function East() {
            var vb = VB()
            vb[0] += danwei
            SetVB(vb)
        }
        function North() {
            var vb = VB()
            vb[1] += -danwei
            SetVB(vb)
        }
        function South() {
            var vb = VB()
            vb[1] += danwei
            SetVB(vb)
        }
        function Up() {
            //放大
            var vb = VB()
            vb[2] += updowndanwei
            vb[3] += updowndanwei
            SetVB(vb)
        }
        function Down() {
            //放xiao
            var vb = VB()
            if (vb[2] > updowndanwei && vb[3] > updowndanwei) {
                vb[2] += -updowndanwei
                vb[3] += -updowndanwei
                SetVB(vb)
            }
        }
        function Up2() {
            //放大
            var vb = VB()
            vb[0] += -updowndanwei / 2
            vb[1] += -updowndanwei / 2
            vb[2] += updowndanwei / 2
            vb[3] += updowndanwei / 2
            SetVB(vb)
        }
        function Down2() {
            //放xiao
            var vb = VB()
            if (vb[2] > updowndanwei && vb[3] > updowndanwei) {
                vb[0] += updowndanwei / 2
                vb[1] += updowndanwei / 2
                vb[2] += -updowndanwei / 2
                vb[3] += -updowndanwei / 2
                SetVB(vb)
            }
        }
        function Up3(x, y) {
            //放大
            var vb = VB()
            vb[0] += -updowndanwei / 2
            vb[1] += -updowndanwei / 2
            vb[2] += updowndanwei / 2
            vb[3] += updowndanwei / 2
            SetVB(vb)
        }
        function Down3(x, y) {
            //放xiao
            var vb = VB()
            vb[0] += updowndanwei / 2
            vb[1] += updowndanwei / 2
            vb[2] += -updowndanwei / 2
            vb[3] += -updowndanwei / 2
            SetVB(vb)
        }
        function SetVB(vb) {
            document.getElementById('linemap').setAttribute('viewBox', `${vb[0]} ${vb[1]} ${vb[2]} ${vb[3]}`)
        }
        function SvgMapDrag(svgId) {
            var MaxX = ThisCity.subwaymapData.x * 1.1 + 100
            var MaxY = ThisCity.subwaymapData.y * 1.1 + 100
            const svgElement = document.getElementById(svgId);
            const svgRect = svgElement.getBoundingClientRect();
            let startX, startY;

            svgElement.addEventListener('mousedown', function (e) {
                if ((CtrlKey && svgId == 'linemapedit') == false) {
                    startX = e.clientX - svgRect.left;
                    startY = e.clientY - svgRect.top;
                    svgElement.style.cursor = 'grabbing';
                }
            });

            svgElement.addEventListener('mousemove', function (e) {
                if (e.buttons === 1) {
                    if ((CtrlKey || AltKey || ShiftKey) == false) {
                        const dx = e.clientX - svgRect.left - startX;
                        const dy = e.clientY - svgRect.top - startY;
                        const currentViewBox = svgElement.viewBox.baseVal;
                        currentViewBox.x += -dx;
                        currentViewBox.y += -dy;
                        startX = e.clientX - svgRect.left;
                        startY = e.clientY - svgRect.top;
                    }
                }
            });

            svgElement.addEventListener('mouseup', function () {
            });

            svgElement.addEventListener('wheel', function (e) {
                e.preventDefault();
                scaleFactor = 200
                const currentViewBox = svgElement.viewBox.baseVal;
                if (e.deltaY > 0) {
                    currentViewBox.width += scaleFactor
                    currentViewBox.height += scaleFactor
                    currentViewBox.x -= scaleFactor / 2;
                    currentViewBox.y -= scaleFactor / 4;
                }
                else if (currentViewBox.width > scaleFactor && currentViewBox.height > scaleFactor) {
                    currentViewBox.width += -scaleFactor
                    currentViewBox.height += -scaleFactor
                    currentViewBox.x -= -scaleFactor / 2;
                    currentViewBox.y -= -scaleFactor / 4;
                }
            });
        }
        function LimitVB(svgElement) {
            var currentViewBox2 = svgElement.viewBox.baseVal;
            if (MaxX < currentViewBox2.x + currentViewBox2.width) {
                currentViewBox2.width -= 10
            }
        }
        SvgMapDrag('linemap')
        SvgMapDrag('linemapedit')
        SvgMapDrag('realmap')
        function CircleMoveDown(classn) {
            var ite = FindOneThisClass(classn)
            ite.isDragging = true;
            ThenMouseMoveWhatItem = classn
        }
        function Forever() {
            IsABStationF = IsABStation(TheLastCreatedPoint.name, TheLastCreatedPoint.line, TheNextCreatedPoint.name, TheNextCreatedPoint.line)
            WriteById('AddingLine', ThisCity.lineweb[AddingLine][0])
            WriteById('AddingStation1', ThisCity.lineweb[AddingLine][AddingStation])
            WriteById('AddingStation2', ThisCity.lineweb[AddingLine][AddingStation + 1])
            document.getElementById('AddingLineColor').style.color = ThisCity.lineweb[AddingLine][1]
            document.getElementById('AddingLineColor').style.backgroundColor = ThisCity.lineweb[AddingLine][1]
            ShuaXinYouCe()
            ShuaXinYouCeMiddleway()
            ReloadStationNotHavePosition()
        }
        setInterval(() => { Forever() }, 100);
        document.addEventListener('mousemove', function (event) {
            var x = event.clientX;
            var y = event.clientY;
            MouseX = x
            MouseY = y
            zuob = screenToSVG(svg, MouseX, MouseY)
            const cx = zuob.x
            const cy = zuob.y
            WriteById('NowX', parseInt(cx))
            WriteById('NowY', parseInt(cy))
            if (ThenMouseMoveWhatItem != '' && CtrlKey) {
                ite = FindOneThisClass(ThenMouseMoveWhatItem)
                Thenx = ite.getAttribute('cx')
                Theny = ite.getAttribute('cy')
                if (Math.abs(Thenx - cx) < 123 && Math.abs(Theny - cy) < 123) {
                    ite.setAttribute('cx', cx);
                    ite.setAttribute('cy', cy);
                }
            }
        });
        function CircleMoveUp(id) {
            var ite = FindOneThisClass(id)
            ite.isDragging = false;
            ThenMouseMoveWhatItem = ''
        }
        function ClearAllThisClassWhenCtrlRight(id) {
            if (CtrlKey) {
                ClearAllThisClass(id)
            }
        }
        // 获取SVG元素
        var svg = document.getElementById('linemapedit');
        // 添加鼠标点击事件监听器
        svg.addEventListener('click', function (event) {
            //获取还有谁不在！
            var StationThatNotHavePosition = FindStationThatNotHavePosition()
            if (StationThatNotHavePosition.length > 1) {
                //WriteById('ticizhan', StationThatNotHavePosition[1].name)
                //WriteById('ticixian', StationThatNotHavePosition[1].line)
                //document.getElementById('ticise').style.backgroundColor = GetColorByLineName(StationThatNotHavePosition[1].line)
                //document.getElementById('ticise').style.color = GetColorByLineName(StationThatNotHavePosition[1].line)
            }
            else {
                WriteById('ticizhan', '/')
                WriteById('ticixian', '/')
                document.getElementById('ticise').style.backgroundColor = "white"
                document.getElementById('ticise').style.color = "white"
            }
            // 获取鼠标位置
            zuob = screenToSVG(svg, event.clientX, event.clientY)
            if (ShiftKey) {
                if (StationThatNotHavePosition.length != 0 && ShiftKey) {

                    // 创建圆
                    var circle = `<circle
  cx="${zuob.x}"      
  cy="${zuob.y}"     
  r="${ThisCity.subwaymapData.stationR / 1.5}"            
  fill="green"      
  fill-opacity="0.85"  
  id="EditorCircle"
  line="${StationThatNotHavePosition[0].line}"
  class="${StationThatNotHavePosition[0].name}|${StationThatNotHavePosition[0].line}"
  oncontextmenu="DeleteByNameLine('${StationThatNotHavePosition[0].name}','${StationThatNotHavePosition[0].line}')"
  onmousedown="CircleMoveDown('${StationThatNotHavePosition[0].name}|${StationThatNotHavePosition[0].line}')"
  onmouseup="CircleMoveUp('${StationThatNotHavePosition[0].name}|${StationThatNotHavePosition[0].line}')"
  isDragging=false
><title>${StationThatNotHavePosition[0].name}|${StationThatNotHavePosition[0].line}</title></circle>`

                    // 将圆添加到SVG
                    AddById('linemapedit', circle);
                    TheLastCreatedPoint.line = StationThatNotHavePosition[0].line
                    TheLastCreatedPoint.name = StationThatNotHavePosition[0].name

                    TheNextCreatedPoint.line = StationThatNotHavePosition[1].line
                    TheNextCreatedPoint.name = StationThatNotHavePosition[1].name

                    IsABStationF = IsABStation(TheLastCreatedPoint.name, TheLastCreatedPoint.line, TheNextCreatedPoint.name, TheNextCreatedPoint.line)
                    MiddleWayIndex = 0
                    WriteById('shangyigelurudeshi', `${StationThatNotHavePosition[0].name}|${StationThatNotHavePosition[0].line}`)
                    ShuaXinYouCe()
                }
            }
            else if (AltKey) {
                //中间点
                // 创建圆
                var CircleClass = `${ThisCity.lineweb[AddingLine][AddingStation]}|${ThisCity.lineweb[AddingLine][0]}|${ThisCity.lineweb[AddingLine][AddingStation + 1]}|${ThisCity.lineweb[AddingLine][0]}|${AddingMiddleWayIndex}`
                var circle = `<circle
  cx="${zuob.x}"      
  cy="${zuob.y}"     
  r="${ThisCity.subwaymapData.stationR / 2.4}"            
  fill="blueviolet"      
  fill-opacity="0.87"  
  id="MiddleWayCircle"
  line="${ThisCity.lineweb[AddingLine][0]}"
  class="${CircleClass}"
  oncontextmenu="ClearAllThisClassWhenCtrlRight('${CircleClass}')"
  onmousedown="CircleMoveDown('${CircleClass}')"
  onmouseup="CircleMoveUp('${CircleClass}')"
  isDragging=false
><title>${CircleClass}</title></circle>`

                // 将圆添加到SVG
                AddById('linemapedit', circle);
                ShuaXinYouCeMiddleway()
                AddingMiddleWayIndex += 1
            }
        });
        svg.addEventListener('contextmenu', function (event) {
            if (ShiftKey && IsABStation(TheLastCreatedPoint.name, TheLastCreatedPoint.line, TheNextCreatedPoint.name, TheNextCreatedPoint.line, MiddleWayIndex)) {
                zuob = screenToSVG(svg, event.clientX, event.clientY)
                //中间点
                // 创建圆
                var CircleClass = `${TheLastCreatedPoint.name}|${TheLastCreatedPoint.line}|${TheNextCreatedPoint.name}|${TheNextCreatedPoint.line}|${MiddleWayIndex}`
                var circle = `<circle
  cx="${zuob.x}"      
  cy="${zuob.y}"     
  r="${ThisCity.subwaymapData.stationR / 2.5}"            
  fill="blue"      
  fill-opacity="0.85"  
  id="MiddleWayCircle"
  line="${TheLastCreatedPoint.line}"
  class="${CircleClass}"
  oncontextmenu="ClearAllThisClassWhenCtrlRight('${CircleClass}')"
  onmousedown="CircleMoveDown('${CircleClass}')"
  onmouseup="CircleMoveUp('${CircleClass}')"
  isDragging=false
><title>${CircleClass}</title></circle>`

                // 将圆添加到SVG
                AddById('linemapedit', circle);
                ShuaXinYouCeMiddleway()
                MiddleWayIndex += 1
            }
            else if (AltKey) {
                if (ThisCity.lineweb[AddingLine].length - 2 == AddingStation) {
                    if (ThisCity.lineweb.length - 1 != AddingLine) {
                        AddingLine += 1
                        AddingStation = 2
                        AddingMiddleWayIndex = 0
                    }
                    else {

                        AddingLine = 0
                        AddingStation = 2
                        AddingMiddleWayIndex = 0
                    }
                }
                else {
                    AddingStation += 1;
                    AddingMiddleWayIndex = 0
                }
            }
        })
        RemoveTwiceAppearPosition()
    </script>
    <br><br><br>
    <table id="lujing">
        <tbody id="tablere">

        </tbody>
    </table>
    <style>
        .换乘文本 {
            font-size: medium;
            color: #555555;
        }

        .leftui {
            position: relative;
        }

        .链接换乘 {
            color: #555555;
        }

        .换乘 {
            color: #555555;
            font-size: medium;
        }

        .换乘预留 {
            font-size: medium;
        }

        #lujing.table {
            border-collapse: collapse;
            padding: 0;
        }

        #lujing.tr,
        #lujing.td {
            padding: 0;
            margin: 0;
            border: none;
        }

        #lujing.td {
            min-width: 0;
        }

        .链接站 {
            color: #111111;
            text-decoration: none;
        }

        .圆形 {
            background-color: #EEEEEE;
            left: -2.2px;
            right: -3px;
            border-radius: 50%;
            width: 12px;
            height: 12px;
            top: 0px;
            bottom: -6px;
            position: relative;
            border-color: #222222;
            border-radius: 12px;
            border-width: 1px;
            border-style: solid;
        }

        .方形 {
            background-color: #EEEEEE;
            left: -2.2px;
            right: -3px;
            width: 12px;
            height: 12px;
            top: 0px;
            bottom: -6px;
            position: relative;
            border-color: #222222;
            border-radius: 0px;
            border-width: 1px;
            border-style: solid;
        }

        .普通站 {
            background-color: #EEEEEE;
            left: 3px;
            right: -3px;
            width: 6px;
            height: 6px;
            top: 0px;
            bottom: -6px;
            position: relative;
        }

        .juxing {
            height: 48px;
            width: 8px;
            left: 16px;
            right: 16px;
            position: relative;
        }

        .tdjx {
            height: 40px;
            width: 40px;
            position: relative;
            left: 16px;
            right: 16px;
        }

        .tdjxnew {
            height: 40px;
            width: 40px;
            position: relative;
            left: 16px;
            right: 16px;
        }

        .tdjxold {
            height: 40px;
            width: 40px;
            position: relative;
            left: 16px;
            right: 16px;
        }

        .站 {
            color: #111111;
            left: 10px;
            top: -20px;
            bottom: -20px;
            font-size: large;
            position: relative;
        }

        .站s {
            color: #111111;
            left: 10px;
            top: -20px;
            bottom: -20px;
            font-size: small;
            position: relative;
        }

        a,
        div {
            text-decoration: none;
        }

        .w {
            color: white
        }
    </style>
    <style>
        /* 基本样式 */
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sansserif;
        }

        .content {
            padding: 20px;
        }

        /* 悬浮窗样式 */
        .floatingwindow {
            position: absolute;
            user-select: none;
            /* 使窗口位置固定 */
            width: 230px;
            /* 宽度 */
            background-color: #f9f9f9;
            /* 背景色 */
            border: 1px solid #ccc;
            /* 边框 */
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            /* 阴影 */
            top: 50px;
            z-index: 40;
        }

        .floatingwindow2 {
            position: absolute;
            left: 250px;
            user-select: none;
            /* 使窗口位置固定 */
            width: 100px;
            /* 宽度 */
            background-color: #f9f9f9;
            /* 背景色 */
            border: 1px solid #ccc;
            /* 边框 */
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            /* 阴影 */
            top: 50px;
            z-index: 40;
        }

        .floatingwindowEnd {
            position: absolute;
            user-select: none;
            /* 使窗口位置固定 */
            width: 230px;
            /* 宽度 */
            background-color: #f9f9f9;
            /* 背景色 */
            border: 1px solid #ccc;
            /* 边框 */
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            /* 阴影 */
            top: 50px;
            z-index: 40;
        }

        .floatingwindow2End {
            position: absolute;
            left: 250px;
            user-select: none;
            /* 使窗口位置固定 */
            width: 100px;
            /* 宽度 */
            background-color: #f9f9f9;
            /* 背景色 */
            border: 1px solid #ccc;
            /* 边框 */
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            /* 阴影 */
            top: 50px;
            z-index: 40;
        }

        .floatingwindowPoint {
            position: absolute;
            user-select: none;
            /* 使窗口位置固定 */

            /* 宽度 */
            background-color: #f9f9f9;
            /* 背景色 */
            border: 1px solid #9b9a9a;
            /* 边框 */
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            /* 阴影 */
            z-index: 40;
        }
    </style>
</body>

</html>
<script>

    document.addEventListener('contextmenu', function (event) {
        event.preventDefault();
    });

    //先刷新一下
    reloadmap()
    ReloadZhanju()
    window.addEventListener('beforeunload', function (event) {
        const confirmationMessage = "确定要离开此页面吗？您所做的更改可能不会被保存。";

        event.preventDefault();
        event.returnValue = confirmationMessage;

        return confirmationMessage;
    });
</script>